Skip to content

Commit 103324e

Browse files
committed
More graceful handling of internal and restricted URLs.
1 parent 5217db7 commit 103324e

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/bg/RequestGuard.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ var RequestGuard = (() => {
314314

315315

316316
const ABORT = {cancel: true}, ALLOW = {};
317+
const INTERNAL_SCHEME = /^(?:chrome|resource|moz-extension|about):/;
317318
const listeners = {
318319
onBeforeRequest(request) {
319320
try {
@@ -324,7 +325,7 @@ var RequestGuard = (() => {
324325
let {url, originUrl, documentUrl} = request;
325326
if (("fetch" === policyType || "frame" === policyType) &&
326327
(url === originUrl && originUrl === documentUrl ||
327-
/^(?:chrome|resource|moz-extension|about):/.test(originUrl))
328+
INTERNAL_SCHEME.test(originUrl))
328329
) {
329330
// livemark request or similar browser-internal, always allow;
330331
return ALLOW;
@@ -334,7 +335,8 @@ var RequestGuard = (() => {
334335
request._dataUrl = url;
335336
request.url = url = documentUrl;
336337
}
337-
let allowed = !ns.isEnforced(request.tabId) ||
338+
let allowed = INTERNAL_SCHEME.test(url) ||
339+
!ns.isEnforced(request.tabId) ||
338340
policy.can(url, policyType, originUrl);
339341
Content.reportTo(request, allowed, policyType);
340342

src/ui/popup.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,14 @@ addEventListener("unload", e => {
130130
} catch (e) {
131131
error(e, "Could not run scripts on %s: privileged page?", tab.url);
132132
}
133-
if (!isHttp) {
133+
134+
await include("/lib/restricted.js");
135+
let isRestricted = isRestrictedURL(tab.url);
136+
if (!isHttp || isRestricted) {
134137
showMessage("warning", _("privilegedPage"));
135138
let tempTrust = document.getElementById("temp-trust-page");
136139
tempTrust.disabled = true;
140+
return;
137141
}
138142
if (!UI.seen) {
139143
if (!isHttp) return;

0 commit comments

Comments
 (0)