Make sure that we don't try to double-encode params using the traditional style. Fixes #6041.
This commit is contained in:
parent
43b3ed086d
commit
54bd004e53
|
@ -624,7 +624,7 @@ jQuery.extend({
|
||||||
// If traditional, encode the "old" way (the way 1.3.2 or older
|
// If traditional, encode the "old" way (the way 1.3.2 or older
|
||||||
// did it), otherwise encode params recursively.
|
// did it), otherwise encode params recursively.
|
||||||
for ( var prefix in a ) {
|
for ( var prefix in a ) {
|
||||||
buildParams( prefix, a[prefix] );
|
buildParams( traditional ? prefix : prefix.replace(/[\[\]]/g, ""), a[prefix] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,7 @@ test("serialize()", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("jQuery.param()", function() {
|
test("jQuery.param()", function() {
|
||||||
expect(18);
|
expect(19);
|
||||||
|
|
||||||
equals( !jQuery.ajaxSettings.traditional, true, "traditional flag, falsy by default" );
|
equals( !jQuery.ajaxSettings.traditional, true, "traditional flag, falsy by default" );
|
||||||
|
|
||||||
|
@ -379,6 +379,8 @@ test("jQuery.param()", function() {
|
||||||
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
|
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
|
||||||
equals( jQuery.param(params,true), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=undefined&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" );
|
equals( jQuery.param(params,true), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=undefined&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" );
|
||||||
|
|
||||||
|
equals( decodeURIComponent( jQuery.param({ "test[]": [0, 1, 2] }) ), "test[]=0&test[]=1&test[]=2", "Make sure params are double-encoded." );
|
||||||
|
|
||||||
jQuery.ajaxSetup({ traditional: true });
|
jQuery.ajaxSetup({ traditional: true });
|
||||||
|
|
||||||
var params = {foo:"bar", baz:42, quux:"All your base are belong to us"};
|
var params = {foo:"bar", baz:42, quux:"All your base are belong to us"};
|
||||||
|
|
Loading…
Reference in a new issue