- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 843
Closed
Activity
Good point, can we work around that @tdeekens?
As far as I remember it was needed to either get the node.global or the window. Suggestions welcome.
Not sure if moving to https://github.com/purposeindustries/window-or-global/blob/master/lib/index.js would solve the issue while still be working.
The problem with the library is that this will be rewritten to undefined using rollup (https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined). I am not really sure what the "semantics" behind the idea for "root" at say
Lines 1 to 12 in a992d3a
| ;(function(factory) { | |
| 'use strict'; | |
| /* global window: false, define: false, module: false */ | |
| var root = typeof window === 'undefined' ? null : window; | |
| if (typeof define === 'function' && define.amd) { | |
| define(function(){ return factory(root); }); | |
| } else if (typeof module !== 'undefined') { | |
| module.exports = factory(root); | |
| } else { | |
| root.DOMPurify = factory(root); | |
| } |
factory was used and interacted with which we can't do now as we bundle the library up.Check #250
As described in the CSP spec, using
Function(...)with a string requires the "unsafe-eval" CSP rule.This is now the case with the implementation of
getGlobal:DOMPurify/src/purify.js
Lines 5 to 8 in 6185fe5
I'm not sure why this pattern is used here. I guess you want to be sure to get the global object.
Do you think you can release a CSP compliant version of DOMPurify, which just returns
window?