Skip to content
This repository has been archived by the owner on Feb 1, 2025. It is now read-only.

Commit

Permalink
Fix unsafe-eval CSP violation - closes #336 (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin-Dobell authored and benjamn committed Aug 3, 2018
1 parent 7834cec commit 4efc689
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/regenerator-runtime/runtime-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

// This method of obtaining a reference to the global object needs to be
// kept identical to the way it is obtained in runtime.js
var g = (function() { return this })() || Function("return this")();
var g = (function() {
return this || (typeof self === "object" && self);
})() || Function("return this")();

// Use `getOwnPropertyNames` because not all browsers support calling
// `hasOwnProperty` on the global `self` object in a worker. See #183.
Expand Down
4 changes: 3 additions & 1 deletion packages/regenerator-runtime/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,5 +715,7 @@
// In sloppy mode, unbound `this` refers to the global object, fallback to
// Function constructor if we're in global strict mode. That is sadly a form
// of indirect eval which violates Content Security Policy.
(function() { return this })() || Function("return this")()
(function() {
return this || (typeof self === "object" && self);
})() || Function("return this")()
);

0 comments on commit 4efc689

Please sign in to comment.