Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'unsafe-eval' CSP issue #2672

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cherniavskii
Copy link

Summary

Fixes #713
See #713 (comment) for explanation.
I've used patch-package to patch the jszip dependency that is using new Function() that violates CSP rules.
The new build of exceljs doesn't include the new Function() anymore.

Test plan

I'll prepare before/after demos later as it's tricky to do with Codesandbox/Stackblitz

Related to source code (for typings update)

@@ -53,8 +53,6 @@ spec/integration/data/gold
/spec/manual/public/exceljs.js
/spec/manual/public/exceljs.min.js

package-lock.json
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patch-package requires package-lock to work. I can extract this to a separate PR if necessary

Comment on lines +9 to +12
- // Callback can either be a function or a string
- if (typeof callback !== "function") {
- callback = new Function("" + callback);
- }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We never pass a string to setImmediate, so it's safe to remove.

The changes below in jszip.min.js are the same, but the diff looks weird because it's a single-line file 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uncaught EvalError: 'unsafe-eval' is not an allowed source of script in the following Content
1 participant