views:

563

answers:

3

What are the reasons behind URLEncodedFormat() escaping valid URL characters?

valid characters:

- _ . ! ~ * " ( )

The CF8 Doc said, "[URLEncodedFormat() escapes] non-alphanumeric characters with equivalent hexadecimal escape sequences." However, why escape valid URL characters?

+7  A: 

They are valid, but it seems pretty normal to me that if you ask a programming language to url encode a string that it converts all non alpha numeric chars to the hex equivalent.

ASP's Server.URLEncode() does the same and php urlencode() does too except for - and _. Also, in javascript, the encodeURIComponent() function will encode all non alpha numeric chars to hex equivalents.

This is a good idea anyway to encode all non alpha numeric characters when using user input for forming server requests to prevent anything unexpected from happening.

Jayson
+1  A: 

Is the encoding of valid url characters causing an error or a problem?

One issue might be that by not doing so, if you embed a link with non-encoded characters in an email, the email software may decide to break the link into two lines.

If you use a fully encoded url though, the chances of this are greatly reduced. Just one way of seeing it though.

Jas Panesar
A: 

I could see at least in the case of " that it would be nice to have it encoded when using the URL as a link in an anchor tag.

Tom Hubbard