From d04aa313fc3a932130be2aabb3c916cf4dce50a7 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Mon, 13 Aug 2018 15:13:59 +0300 Subject: [PATCH] CSP Fix. fixes #215 --- core/src/main.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main.js b/core/src/main.js index a7c712ee..d6694afc 100644 --- a/core/src/main.js +++ b/core/src/main.js @@ -257,9 +257,11 @@ export class BetterDiscord { session.defaultSession.webRequest.onHeadersReceived((details, callback) => { for (let [header, values] of Object.entries(details.responseHeaders)) { if (!header.match(/^Content-Security-Policy(-Report-Only)?$/i)) continue; + details.responseHeaders[header] = values.map(value => { const policy = new ContentSecurityPolicy(value); for (const [key, value] of Object.entries(CSP)) { + if (!policy.get(key)) continue; policy.add(key, value.join(' ')); } return policy.toString();