Bug 1621935 - Allow webRequest to see subresource requests in local files r=mixedpuppy

And remove the explicit "baseURL" origin check. This check was meant to
ensure that extensions can always intercept requests that it generated,
but changed in https://hg.mozilla.org/mozilla-central/rev/cd219dd096 by
accident to allowing access to the real `jar:`/`file:`-URL that backs
the `moz-extension:`-protocol handler.

That mistake did not break functionality, because the check was
redundant: the `moz-extension:`-origin is already explicitly added to
the internal set of host permissions of an extension. This scenario is
covered by the existing test_ext_webRequest_from_extension_page.js test.

Differential Revision: https://phabricator.services.mozilla.com/D67735
This commit is contained in:
Rob Wu
2020-03-24 18:58:46 +00:00
parent 67333f7e0d
commit 14019f85b9
4 changed files with 82 additions and 11 deletions

View File

@@ -572,7 +572,7 @@ bool ChannelWrapper::Matches(
bool isProxy =
aOptions.mIsProxy && aExtension->HasPermission(nsGkAtoms::proxy);
// Proxies are allowed access to all urls, including restricted urls.
if (!aExtension->CanAccessURI(urlInfo, false, !isProxy)) {
if (!aExtension->CanAccessURI(urlInfo, false, !isProxy, true)) {
return false;
}
@@ -583,14 +583,12 @@ bool ChannelWrapper::Matches(
return false;
}
if (auto origin = DocumentURLInfo()) {
nsAutoCString baseURL;
aExtension->GetBaseURL(baseURL);
if (!StringBeginsWith(origin->CSpec(), baseURL) &&
!aExtension->CanAccessURI(*origin)) {
return false;
}
auto origin = DocumentURLInfo();
// Extensions with the file:-permission may observe requests from file:
// origins, because such documents can already be modified by content
// scripts anyway.
if (origin && !aExtension->CanAccessURI(*origin, false, true, true)) {
return false;
}
}
}