raku-community-modules / URI

Raku realization of URI — Uniform Resource Identifiers handler
Artistic License 2.0
3 stars 14 forks source link

uri_escape incorrectly encodes spaces as "+" #1

Closed pmichaud closed 9 years ago

pmichaud commented 9 years ago

URI::Escape incorrectly encodes spaces as "+" in its output. Test:

say uri_escape("10% is enough");

Currently outputs:

10%25+is+enough%0A

Correct output:

10%25%20is%20enough%0A

Discussion: The handling of spaces in URLs and forms is often confusing. RFC 3986 is the standard this module claims to implement, and RFC 3986 encodes spaces as "%20". The confusion arises from the application/x-www-form-urlencoded component of HTML, which says that spaces are to be encoded as plus-signs for FORM submissions. This space->plus translation applies only to the form data itself (in the body of a POST request or in the query component of a URL) and is not part of RFC 3986. In the components of the URL before the query part, including the path, spaces must be percent-encoded.

Or, put another way, "form data encoding" is not exactly the same as "uri encoding" and applies only to the query part of a URL.

Pm

pmichaud commented 9 years ago

This bug also affects https://github.com/perl6/doc/issues/27 .

moritz commented 9 years ago

Fixed in commit 174f28ddd515b7ecb4e4d530fedf1a801211995a, thanks for the detailed report!