PDA

View Full Version : [CLOSED]Ext.urlDecode could loose some data after second = char



Traktopel
28 Jun 2010, 12:18 AM
Ext version tested:


Ext 3.2.2



Adapter used:


ext




Browser versions tested against:


FF3 (firebug 1.5.3 installed)



Operating System:


Win 7



Description:


If a token in your url contains more thant one equal symbol ... (ie : url?...&code=YWR=taW4) the string will not take account on what characters are behind the second equal



Test Case:



var urlArgsDecoded = Ext.urlDecode("http://localhost/index.html?code=YWR=taW4");


Possible fix:

urlDecode : function(string, overwrite){
if(Ext.isEmpty(string)){
return {};
}
var obj = {},
pairs = string.split('&'),
d = decodeURIComponent,
name,
value;
Ext.each(pairs, function(pair) {
pair = pair.split('=');
name = d(pair[0]);
pair.remove(pair[0]);
value = d(pair.join('='));
//value = d(pair[1]);
obj[name] = overwrite || !obj[name] ? value :
[].concat(obj[name]).concat(value);
});
return obj;
},

Condor
28 Jun 2010, 2:52 AM
That isn't a valid URL. It should be:

http://localhost/index.html?code=YWR%3DtaW4

Traktopel
28 Jun 2010, 3:11 AM
My bad, sorry.

Thanks Condor