String.QueryString: fix bug decoding '+' #1313

Closed
wants to merge 2 commits into
from

Projects

None yet

4 participants

@danielbeardsley
Contributor

decodeURIComponent doesn't do the correct thing with query parameter
keys or values. Specifically, it leaves '+' as '+' when it should be
converting them to spaces as that's the specification. When browsers
submit HTML forms via GET, the values are encoded using
the 'application/x-www-form-urlencoded' mime type which converts
spaces to '+'. decodeURIComponent() will then give incorrect results
on components of the query string.

See: http://unixpapa.com/js/querystring.html for a description of the
problem.

@danielbeardsley danielbeardsley String.QueryString: fix bug decoding '+'
decodeURIComponent doesn't do the correct thing with query parameter
keys or values. Specifically, it leaves '+' as '+' when it should be
converting them to spaces as that's the specification. When browsers
submit HTML forms via GET, the values are encoded using
the 'application/x-www-form-urlencoded' mime type which converts
spaces to '+'. decodeURIComponent() will then give incorrect results
on components of the query string.

See: http://unixpapa.com/js/querystring.html for a description of the
problem.
ce3c308
@SergioCrisostomo SergioCrisostomo added this to the 1.5.2 milestone Jun 25, 2015
@sctice sctice String.QueryString: Replace multiple '+'
String.replace only replaces the first occurrence when the search is specified
as a string.
5a5cdae
@danielbeardsley
Contributor

Thanks @sctice !

@SergioCrisostomo
Member

LGTM 👍

@anutron
Member
anutron commented Aug 10, 2015

👍

@SergioCrisostomo
Member

added via 8abfa00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment