mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Fixes #8509. Makes URL regexp less overzealous and ensures it recognizes URL schemes which do not contain a conformant hierarchical structure ( as per section 2.1.2 of http://www.ietf.org/rfc/rfc2718.txt ). Also adds about: and adobe air's app: and app-storage: to the list of local protocols and provides a failover in case document.location is illformed. Unit test added.
This commit is contained in:
parent
6c124d3dd4
commit
714ae379db
@ -7,7 +7,7 @@ var r20 = /%20/g,
|
|||||||
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
|
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
|
||||||
rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
|
rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
|
||||||
// #7653, #8125, #8152: local protocol detection
|
// #7653, #8125, #8152: local protocol detection
|
||||||
rlocalProtocol = /(?:^file|^widget|\-extension):$/,
|
rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|widget):$/,
|
||||||
rnoContent = /^(?:GET|HEAD)$/,
|
rnoContent = /^(?:GET|HEAD)$/,
|
||||||
rprotocol = /^\/\//,
|
rprotocol = /^\/\//,
|
||||||
rquery = /\?/,
|
rquery = /\?/,
|
||||||
@ -19,7 +19,7 @@ var r20 = /%20/g,
|
|||||||
rucHeadersFunc = function( _, $1, $2 ) {
|
rucHeadersFunc = function( _, $1, $2 ) {
|
||||||
return $1 + $2.toUpperCase();
|
return $1 + $2.toUpperCase();
|
||||||
},
|
},
|
||||||
rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?|\/[^\/])/,
|
rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
|
||||||
|
|
||||||
// Keep a copy of the old load method
|
// Keep a copy of the old load method
|
||||||
_load = jQuery.fn.load,
|
_load = jQuery.fn.load,
|
||||||
@ -61,7 +61,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Segment location into parts
|
// Segment location into parts
|
||||||
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() );
|
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
|
||||||
|
|
||||||
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
|
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
|
||||||
function addToPrefiltersOrTransports( structure ) {
|
function addToPrefiltersOrTransports( structure ) {
|
||||||
|
@ -492,7 +492,7 @@ test(".ajax() - hash", function() {
|
|||||||
|
|
||||||
test("jQuery ajax - cross-domain detection", function() {
|
test("jQuery ajax - cross-domain detection", function() {
|
||||||
|
|
||||||
expect( 5 );
|
expect( 6 );
|
||||||
|
|
||||||
var loc = document.location,
|
var loc = document.location,
|
||||||
otherPort = loc.port === 666 ? 667 : 666,
|
otherPort = loc.port === 666 ? 667 : 666,
|
||||||
@ -508,6 +508,7 @@ test("jQuery ajax - cross-domain detection", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
|
dataType: "jsonp",
|
||||||
url: 'app:/path',
|
url: 'app:/path',
|
||||||
beforeSend: function( _ , s ) {
|
beforeSend: function( _ , s ) {
|
||||||
ok( s.crossDomain , "Adobe AIR app:/ URL detected as cross-domain" );
|
ok( s.crossDomain , "Adobe AIR app:/ URL detected as cross-domain" );
|
||||||
@ -533,6 +534,15 @@ test("jQuery ajax - cross-domain detection", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jQuery.ajax({
|
||||||
|
dataType: "jsonp",
|
||||||
|
url: "about:blank",
|
||||||
|
beforeSend: function( _ , s ) {
|
||||||
|
ok( s.crossDomain , "Test about:blank is detected as cross-domain" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
dataType: "jsonp",
|
dataType: "jsonp",
|
||||||
url: loc.protocol + "//" + loc.host,
|
url: loc.protocol + "//" + loc.host,
|
||||||
|
Loading…
Reference in New Issue
Block a user