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
da3ff3af
Commit
da3ff3af
authored
Oct 03, 2012
by
Richard Gibson
Committed by
Dave Methvin
Oct 04, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12637: restore 1.8.1 ajax crossDomain logic. Close gh-944.
parent
ebf4d430
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
ajax.js
src/ajax.js
+6
-3
ajax.js
test/unit/ajax.js
+11
-1
No files found.
src/ajax.js
View file @
da3ff3af
...
@@ -580,9 +580,12 @@ jQuery.extend({
...
@@ -580,9 +580,12 @@ jQuery.extend({
// A cross-domain request is in order when we have a protocol:host:port mismatch
// A cross-domain request is in order when we have a protocol:host:port mismatch
if
(
s
.
crossDomain
==
null
)
{
if
(
s
.
crossDomain
==
null
)
{
parts
=
rurl
.
exec
(
s
.
url
.
toLowerCase
()
)
||
false
;
parts
=
rurl
.
exec
(
s
.
url
.
toLowerCase
()
);
s
.
crossDomain
=
parts
&&
(
parts
.
join
(
":"
)
+
(
parts
[
3
]
?
""
:
parts
[
1
]
===
"http:"
?
80
:
443
)
)
!==
s
.
crossDomain
=
!!
(
parts
&&
(
ajaxLocParts
.
join
(
":"
)
+
(
ajaxLocParts
[
3
]
?
""
:
ajaxLocParts
[
1
]
===
"http:"
?
80
:
443
)
);
(
parts
[
1
]
!==
ajaxLocParts
[
1
]
||
parts
[
2
]
!==
ajaxLocParts
[
2
]
||
(
parts
[
3
]
||
(
parts
[
1
]
===
"http:"
?
80
:
443
)
)
!=
(
ajaxLocParts
[
3
]
||
(
ajaxLocParts
[
1
]
===
"http:"
?
80
:
443
)
)
)
);
}
}
// Convert data if not already a string
// Convert data if not already a string
...
...
test/unit/ajax.js
View file @
da3ff3af
...
@@ -511,12 +511,22 @@ test(".ajax() - hash", function() {
...
@@ -511,12 +511,22 @@ test(".ajax() - hash", function() {
test
(
"jQuery ajax - cross-domain detection"
,
function
()
{
test
(
"jQuery ajax - cross-domain detection"
,
function
()
{
expect
(
6
);
expect
(
7
);
var
loc
=
document
.
location
,
var
loc
=
document
.
location
,
samePort
=
loc
.
port
||
(
loc
.
protocol
===
"http:"
?
80
:
443
),
otherPort
=
loc
.
port
===
666
?
667
:
666
,
otherPort
=
loc
.
port
===
666
?
667
:
666
,
otherProtocol
=
loc
.
protocol
===
"http:"
?
"https:"
:
"http:"
;
otherProtocol
=
loc
.
protocol
===
"http:"
?
"https:"
:
"http:"
;
jQuery
.
ajax
({
dataType
:
"jsonp"
,
url
:
loc
.
protocol
+
"//"
+
loc
.
host
+
":"
+
samePort
,
beforeSend
:
function
(
_
,
s
)
{
ok
(
!
s
.
crossDomain
,
"Test matching ports are not detected as cross-domain"
);
return
false
;
}
});
jQuery
.
ajax
({
jQuery
.
ajax
({
dataType
:
"jsonp"
,
dataType
:
"jsonp"
,
url
:
otherProtocol
+
"//"
+
loc
.
host
,
url
:
otherProtocol
+
"//"
+
loc
.
host
,
...
...
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