Commit da3ff3af authored by Richard Gibson's avatar Richard Gibson Committed by Dave Methvin

Fix #12637: restore 1.8.1 ajax crossDomain logic. Close gh-944.

parent ebf4d430
...@@ -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
......
...@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment