Opened 13 years ago
Closed 13 years ago
#10319 closed defect (invalid)
dojo.queryToObject() returns different results under IE
Reported by: | Massimo Foti | Owned by: | anonymous |
---|---|---|---|
Priority: | high | Milestone: | 1.4 |
Component: | Core | Version: | 1.4.0b |
Keywords: | queryToObject | Cc: | |
Blocked By: | Blocking: |
Description (last modified by )
The following call returns an object with two entries under FF and Chrome, not in IE 8.
dojo.queryToObject("search%3D%252Fcarta%252Fsearch.json%253Ffulltext%253Da%2526owner%253D%2526lastModificationAuthor%253D%2526tags%253D%2526createdSince%253D2009-11-01%2526updatedSince%253D%2526typeOfFile%253D%26ui%3DheaderType%253Dsearch%2526headerTitle%253DSearch%252520Results");
I discovered this issue while using dojo.back() to handle bookmarks and back/forward buttons. So I am serializing plenty of things inside location.hash, ending up with a "querystring containing querystrings"
I managed to solve this issue adding the line below at the very beginning of queryToObject(): str = dojo.isMozilla ? str : decodeURIComponent(str);
I figured out the need of it by looking at the source of dojo.back, where you can find a private function like this:
function getHash(){
var h = window.location.hash; if(h.charAt(0) == "#"){ h = h.substring(1); } return dojo.isMozilla ? h : decodeURIComponent(h);
}
Looks like IE needs some help, other browsers do just fine, decoding the querystring internally.
Hope it will help
Change History (1)
comment:1 Changed 13 years ago by
Description: | modified (diff) |
---|---|
Resolution: | → invalid |
Status: | new → closed |
The above example decodes the same across browsers, to a string (the string looks like it has an encodeURIComponent done on the whole thing).
The problem is probably how you get the value you are sending to dojo.formToObject. As the dojo.back code shows, where you read the value from can mean that you need to decodeURIComponent before sending to dojo.objectToQuery. But dojo.objectToQuery by itself does no browser-dependent work. It uses decodeURIComponent under the hood for each piece in the chain, but that performs the same across browsers.