View Full Version : [FIXED] Does fromQueryString have a bug in it?

11 Apr 2013, 8:11 PM

If you have a string like:

"doctypes=Correspondence&doctypes=Line+Item" it will decode it into:

Object {doctypes: Array[2]}
doctypes: Array[2]
0: "Correspondence"
1: "Line+Item"
length: 2

It fails to convert the + to a space as expected. This is similar to decodeURIComponent, but I had expected it to behave more like the Python parse_qsl()

The reason I ask is because if you extend that string just a bit:

"doctypes=Correspondence&doctypes=Line+Item%2B" it will decode the second doctypes element as Line+Item+ and at this point, I can't just regex replace the + with a space any longer.

My workaround at the moment is to do the regex replace FIRST

Ext.Object.fromQueryString("doctypes=Correspondence&doctypes=Line+Item%2b".replace(/\+/g,' '))

which does give the right answer, but I'm wondering if I'm missing some edge case.

12 Apr 2013, 7:26 AM
IMO it needs to adhere to the standard as a space can either be '%20' or '+'. A pretty good reference is at http://www.w3schools.com/tags/ref_urlencode.asp (w3schools.com isn't the most accurate but this list is a pretty good reference).

12 Apr 2013, 7:33 AM
Ok, but doesn't fromQueryString mean that it has been translated fromQueryString? You are building a dict of values from the querystring keyed by its values.

In fact I think your statement might have helped in the argument that it is a bug:

Object {foo: "This+is a test"}

The plus survives the fromQueryString but the %20 is converted. This seems to indicate the + should be converted during fromQueryString.

12 Apr 2013, 7:44 AM
Do note that I moved this to the bugs forum and it is marked as open already.