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

Not usable without "unsafe-eval" in script-src #647

Closed
codegain opened this issue Feb 24, 2021 · 2 comments
Closed

Not usable without "unsafe-eval" in script-src #647

codegain opened this issue Feb 24, 2021 · 2 comments
Labels
Bug resolved if issue is resolved, it will be open until merge with master

Comments

@codegain
Copy link

codegain commented Feb 24, 2021

Issue summary

Hi,
I'm using jquery.terminal for quite a while now, but since 2.22.0 it stopped working. I got an CSP error in chrome:

Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'

I narrowed it down to this commit 8b2d6bf and this line added:

var is_browser = new Function('try {return this===window;}catch(e){return false;}')();

This won't be executed if the CSP doesn't contain unsafe-eval in the script-src CSP.

Steps to reproduce

Set a CSP with script-src 'self' and run the terminal.

Browser and OS

Chrome 88 on Windows 10

@jcubic
Copy link
Owner

jcubic commented Feb 24, 2021

I've found this code snippet on StackOverflow but it seems that the Function constructor, that is in fact eval, is not needed.

This works fine:

var is_browser = (function() { try {return this===window;}catch(e){return false;} })()

Thanks for the bug report.

@jcubic jcubic added the Bug label Feb 24, 2021
jcubic added a commit that referenced this issue Feb 24, 2021
@jcubic
Copy link
Owner

jcubic commented Feb 24, 2021

The fix is added, it will be published in next bug fix version. I will try in same version fix the prompt issue.

@jcubic jcubic added the resolved if issue is resolved, it will be open until merge with master label Feb 24, 2021
@jcubic jcubic closed this as completed Apr 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug resolved if issue is resolved, it will be open until merge with master
Projects
None yet
Development

No branches or pull requests

2 participants