-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
CSP violations for unsafe-inline in pdfjst-dist@2.0.943 #10229
Comments
For debugging purposes it will be a lot quicker to just run Just make sure that you follow the steps outlined in https://github.com/mozilla/pdf.js#getting-the-code first, such that the repo is correctly setup locally and the various |
This is a part of generated code, so I don't think there is anything we can do about this. I would suggest to file this issue at the Babel repository instead. Thanks. |
@tomtomau Have run into the same exact problem with the CSP violation on Function("return this") after upgrading and deploying to my server. My browser stops at node_modules/regenerator-runtime/runtime-module.js and there is an issue related to this. facebook/regenerator#336
The fix was merged I think in 0.12.1 https://github.com/facebook/regenerator/releases Assuming this is caused by Babel's use of this library, I see the reference to this library in @babel/runtime (https://github.com/babel/babel/blob/master/packages/babel-runtime/package.json). Babel would need to update and then pdfjs would need to use the new version of babel to create the built version of the pdf.js file. @timvandermeij Would you reconsider opening this as many of use the built viewer and I think we would need to rebuild the build/pdf.js file after babel is updated to use the newest version of runtime-module |
Thank you for looking into this. We regularly update our dependencies, so once Babel fixes this we will upgrade too. |
pdf.js is on Babel 6.26 which pins regenerator-runtime to 0.11 From my understanding - if pdf.js is upgraded to Babel 7.x this problem should be resolved. |
@tomtomau I think you are right. I got stuck in dependency hell and didn't realize that yeah, the new babel should work. As a workaround, if you happen to be using the pre-built pdfjs viewer, you can find references to Function("this") and replace it with the code mentioned in facebook/regenerator#336 |
Yeah thanks, we've just pinned to the older version of pdf.js for now |
@tomtomau Looking at Babel's yarn.lock, they still aren't using regenerator-runtime 0.12.1, so I've written an issue there as well since they will need to explicitly yarn update to 0.12.1 or 0.13 Babel issue: babel/babel#9043 |
Reopening to track the Babel upgrade on our side. Feel free to ping us if the upstream fix is applied and we'll update too. |
The upgrade to Babel 7 is completed in #10293. Closing since there is nothing more we can do on our side now. |
Configuration:
2.0.943
We have a content security policy that prevents
unsafe-inline
.Unfortunately, after upgrading to 2.0.943, pdfjs-dist/build/pdf.js now has a
Function("return this")
call (which violates CSP.My understanding was this was introduced when support for async/await and generators was added to the gulpfile.js.
Upon searching for the babel plugin and finding the GitHub issues, I find only two issues which don't really seem to be covering the issue.
I'm unsure of how to build my own version of pdfjs-dist to try and isolate to see if this is definitively the issue, so just posting this to see if I can get some help/pointers!
The text was updated successfully, but these errors were encountered: