diff options
Diffstat (limited to 'src/bg/ReportingCSP.js')
-rw-r--r-- | src/bg/ReportingCSP.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/bg/ReportingCSP.js b/src/bg/ReportingCSP.js index 825107e..2da1bbc 100644 --- a/src/bg/ReportingCSP.js +++ b/src/bg/ReportingCSP.js @@ -25,6 +25,8 @@ function ReportingCSP(reportURI, reportGroup) { patchHeaders(responseHeaders, capabilities) { let header = null; let needsReportTo = REPORT_TO_SUPPORTED; + + let blocker = capabilities && this.buildFromCapabilities(capabilities); for (let h of responseHeaders) { if (this.isMine(h)) { header = h; @@ -32,10 +34,16 @@ function ReportingCSP(reportURI, reportGroup) { } else if (needsReportTo && h.name === REPORT_TO.name && h.value === REPORT_TO.value) { needsReportTo = false; + } else if (blocker && /^(Location|Refresh)$/i.test(h.name)) { + let url = /^R/i.test(h.name) + ? h.value.replace(/^[^,;]*[,;]url[^\w=]*=\s*/i, "") : h.value; + let patched = CSP.patchDataURI(url, blocker); + if (patched !== url) { + h.value = h.value.slice(0, -url.length) + patched; + } } } - let blocker = capabilities && this.buildFromCapabilities(capabilities); if (blocker) { if (needsReportTo) { responseHeaders.push(REPORT_TO); |