Fixed dynamic script injection breaking images shown as frame content.
This commit is contained in:
parent
093b9d724e
commit
0ad5f95eb4
|
@ -90,9 +90,6 @@ var RequestGuard = (() => {
|
||||||
|
|
||||||
if (what === "noscriptFrame") {
|
if (what === "noscriptFrame") {
|
||||||
let nsf = records.noscriptFrames;
|
let nsf = records.noscriptFrames;
|
||||||
if (frameId in nsf) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
nsf[frameId] = optValue;
|
nsf[frameId] = optValue;
|
||||||
what = optValue ? "blocked" : "allowed";
|
what = optValue ? "blocked" : "allowed";
|
||||||
if (frameId === 0) {
|
if (frameId === 0) {
|
||||||
|
@ -278,18 +275,20 @@ var RequestGuard = (() => {
|
||||||
};
|
};
|
||||||
if (tabId < 0) return;
|
if (tabId < 0) return;
|
||||||
if (pending) request.initialUrl = pending.initialUrl;
|
if (pending) request.initialUrl = pending.initialUrl;
|
||||||
try {
|
if (type !== "sub_frame") { // we couldn't deliver it to frameId, since it's generally not loaded yet
|
||||||
browser.tabs.sendMessage(
|
try {
|
||||||
tabId,
|
await browser.tabs.sendMessage(
|
||||||
{type: "seen", request, allowed, policyType, ownFrame: true},
|
tabId,
|
||||||
{frameId}
|
{type: "seen", request, allowed, policyType, ownFrame: true},
|
||||||
);
|
{frameId}
|
||||||
} catch (e) {
|
);
|
||||||
debug(`Couldn't deliver "seen" message for ${type}@${url} ${allowed ? "A" : "F" } to document ${documentUrl} (${frameId}/${tabId}`, e);
|
} catch (e) {
|
||||||
|
debug(`Couldn't deliver "seen" message for ${type}@${url} ${allowed ? "A" : "F" } to document ${documentUrl} (${frameId}/${tabId})`, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (frameId === 0) return;
|
if (frameId === 0) return;
|
||||||
try {
|
try {
|
||||||
browser.tabs.sendMessage(
|
await browser.tabs.sendMessage(
|
||||||
tabId,
|
tabId,
|
||||||
{type: "seen", request, allowed, policyType},
|
{type: "seen", request, allowed, policyType},
|
||||||
{frameId: 0}
|
{frameId: 0}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
{
|
{
|
||||||
let NULL = new Uint8Array();
|
let NULL = new Uint8Array();
|
||||||
|
let brokenOnLoad = (async () => parseInt(await browser.runtime.getBrowserInfo().version) < 61);
|
||||||
let pendingRequests = new Map();
|
let pendingRequests = new Map();
|
||||||
|
|
||||||
let cleanup = r => {
|
let cleanup = r => {
|
||||||
|
@ -59,7 +60,7 @@
|
||||||
|
|
||||||
let content = this.getContentMetaData(request);
|
let content = this.getContentMetaData(request);
|
||||||
debug(request.url, content.type);
|
debug(request.url, content.type);
|
||||||
if (/\bxml\b/.test(content.type) && !/\bhtml\b/.test(content.type)) return;
|
if (/^[\w/+-]*\b(xml|image)\b/i.test(content.type) && !/\bhtml\b/i.test(content.type)) return;
|
||||||
let filter = browser.webRequest.filterResponseData(requestId);
|
let filter = browser.webRequest.filterResponseData(requestId);
|
||||||
let buffer = [];
|
let buffer = [];
|
||||||
|
|
||||||
|
@ -76,8 +77,10 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
filter.onstart = event => {
|
if (brokenOnLoad) {
|
||||||
filter.write(NULL);
|
filter.onstart = event => {
|
||||||
|
filter.write(NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filter.ondata = event => {
|
filter.ondata = event => {
|
||||||
|
|
Loading…
Reference in New Issue