Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 491
Henry Avatar asked Jun 29 '09 00:06

Henry


People also ask

Which characters should be encoded in URL?

Special characters needing encoding are: ':' , '/' , '?' , '#' , '[' , ']' , '@' , '!' , '$' , '&' , "'" , '(' , ')' , '*' , '+' , ',' , ';' , '=' , as well as '%' itself.

Why is encoding URL important?

Why do we need to encode? URLs can only have certain characters from the standard 128 character ASCII set. Reserved characters that do not belong to this set must be encoded. This means that we need to encode these characters when passing into a URL.

What does %23 mean in a URL?

%23 is the URL encoded representation of # . I suspect your rewrite rules will not satisfy %23 . You ought to investigate how the response is being constructed. Specifically, any URL encoding functions. However, it would be possible to solve your issue with a rewrite rule.


2 Answers

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.

like image 82
Jayson Avatar answered Sep 28 '22 08:09

Jayson


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.

like image 20
Jas Panesar Avatar answered Sep 28 '22 07:09

Jas Panesar