Why does URLEncodedFormat() in CFML encodes valid URL characters?

coldfusion, urlencode

Solution

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.

Problem

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?

Original source