Skip to content

Commit

Permalink
ensure data isn't undefined before csp fallback #140
Browse files Browse the repository at this point in the history
  • Loading branch information
quoid committed Jun 15, 2021
1 parent 1090a55 commit 392f769
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion extension/Userscripts Extension/UserscriptsSafari.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ function cspFallback(e) {
// since it's fair to assume injection was blocked for extension's content script
if (e.effectiveDirective === "script-src") {
// get all "auto" code
if (Object.keys(data.js.auto).length != 0 && cspFallbackAttempted < 1) {
// other extensions can trigger a security policy violation event
// make sure data var is not undefined before attempting fallback
if (data && Object.keys(data.js.auto).length != 0 && cspFallbackAttempted < 1) {
let n = {"js": {"auto": {}}};
n.js.auto = data.js.auto;
parseCode(n, true);
Expand Down

0 comments on commit 392f769

Please sign in to comment.