Skip to content

Commit

Permalink
Try to play nicely with CSP again.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapptz committed Sep 7, 2020
1 parent 57b11b3 commit 44ea225
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions beautifuldiscord/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,11 @@ def revert_changes(discord):
def allow_https():
bypass_csp = textwrap.dedent("""
require("electron").session.defaultSession.webRequest.onHeadersReceived(({ responseHeaders }, done) => {
Object.keys(responseHeaders)
.filter(k => (/^content-security-policy/i).test(k) || (/^x-frame-options/i).test(k))
.map(k => (delete responseHeaders[k]));
let csp = responseHeaders["content-security-policy"];
if (!csp) return done({cancel: false});
let header = csp[0].replace(/connect-src ([^;]+);/, "connect-src $1 https://*;");
header = header.replace(/style-src ([^;]+);/, "style-src $1 https://*;");
responseHeaders["content-security-policy"] = header;
done({ responseHeaders });
});
""")
Expand Down

0 comments on commit 44ea225

Please sign in to comment.