зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1544170 Part 4 - Don't infinitely recurse in newChannelForURL on failure, r=loganfsmyth.
Differential Revision: https://phabricator.services.mozilla.com/D27411 --HG-- extra : rebase_source : 658df8227afa78826ef32b63f87e7c0f9554bda2
This commit is contained in:
Родитель
ee403cec34
Коммит
18578fbd02
|
@ -642,7 +642,7 @@ function mainThreadFetch(urlIn, aOptions = { loadFromCache: true,
|
||||||
* @param {Object} options - The options object passed to @method fetch.
|
* @param {Object} options - The options object passed to @method fetch.
|
||||||
* @return {nsIChannel} - The newly created channel. Throws on failure.
|
* @return {nsIChannel} - The newly created channel. Throws on failure.
|
||||||
*/
|
*/
|
||||||
function newChannelForURL(url, { policy, window, principal }) {
|
function newChannelForURL(url, { policy, window, principal }, recursing = false) {
|
||||||
const securityFlags = Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
|
const securityFlags = Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
|
||||||
|
|
||||||
let uri;
|
let uri;
|
||||||
|
@ -689,11 +689,17 @@ function newChannelForURL(url, { policy, window, principal }) {
|
||||||
try {
|
try {
|
||||||
return NetUtil.newChannel(channelOptions);
|
return NetUtil.newChannel(channelOptions);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
// Don't infinitely recurse if newChannel keeps throwing.
|
||||||
|
if (recursing) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
// In xpcshell tests on Windows, nsExternalProtocolHandler::NewChannel()
|
// In xpcshell tests on Windows, nsExternalProtocolHandler::NewChannel()
|
||||||
// can throw NS_ERROR_UNKNOWN_PROTOCOL if the external protocol isn't
|
// can throw NS_ERROR_UNKNOWN_PROTOCOL if the external protocol isn't
|
||||||
// supported by Windows, so we also need to handle the exception here if
|
// supported by Windows, so we also need to handle the exception here if
|
||||||
// parsing the URL above doesn't throw.
|
// parsing the URL above doesn't throw.
|
||||||
return newChannelForURL("file://" + url, { policy, window, principal });
|
return newChannelForURL("file://" + url, { policy, window, principal },
|
||||||
|
/* recursing */ true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче