Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
54bd004e
Commit
54bd004e
authored
Feb 06, 2010
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that we don't try to double-encode params using the traditional style. Fixes #6041.
parent
43b3ed08
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
ajax.js
src/ajax.js
+1
-1
ajax.js
test/unit/ajax.js
+4
-2
No files found.
src/ajax.js
View file @
54bd004e
...
@@ -624,7 +624,7 @@ jQuery.extend({
...
@@ -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
]
);
}
}
}
}
...
...
test/unit/ajax.js
View file @
54bd004e
...
@@ -351,9 +351,9 @@ test("serialize()", function() {
...
@@ -351,9 +351,9 @@ test("serialize()", function() {
});
});
test
(
"jQuery.param()"
,
function
()
{
test
(
"jQuery.param()"
,
function
()
{
expect
(
1
8
);
expect
(
1
9
);
equals
(
!
jQuery
.
ajaxSettings
.
traditional
,
true
,
"traditional flag, falsy by default"
);
equals
(
!
jQuery
.
ajaxSettings
.
traditional
,
true
,
"traditional flag, falsy by default"
);
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"
};
equals
(
jQuery
.
param
(
params
),
"foo=bar&baz=42&quux=All+your+base+are+belong+to+us"
,
"simple"
);
equals
(
jQuery
.
param
(
params
),
"foo=bar&baz=42&quux=All+your+base+are+belong+to+us"
,
"simple"
);
...
@@ -378,6 +378,8 @@ test("jQuery.param()", function() {
...
@@ -378,6 +378,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
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment