Glavin001 / atom-preview

:construction: (NO LONGER MAINTAINED) :construction: - :eyeglasses: Ultimate previewer of source code in Atom.
https://atom.io/packages/preview
MIT License
51 stars 23 forks source link

'unsafe-eval' EvalError caused by Analytics-Node library #68

Closed deankarn closed 10 years ago

deankarn commented 10 years ago

I'm using Atom 0.134.0 when I toggle Preview the following errors:

Uncaught EvalError: 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'".

all I had in the coffescript file was alert "CoffeeScript!"

Glavin001 commented 10 years ago

I believe this is an issue caused by updating to the latest version of Atom. It is unlikely I will have time to create a patch and fix this before Sunday. I apologize for the inconvenience.

Some notes for anyone interested in submitting a Pull Request: this issue is similar to https://discuss.atom.io/t/--template-causes-unsafe-eval-error/9310 and can be solved by using https://github.com/atom/loophole

The likely afflicting lines of code that need to be wrapped with loophole can be found https://github.com/Glavin001/atom-preview/blob/master/lib/renderer.coffee#L45-L58

Glavin001 commented 10 years ago

I am unable to reproduce in Atom 0.135.0.

Glavin001 commented 10 years ago

Please try published version v0.13.1 and let me know if this resolves your issue.

deankarn commented 10 years ago

I updated to Atom 0.135.0 and updated atom-preview to v0.13.1, yet the same issue persists.

screen shot 2014-10-05 at 10 32 09 am

Glavin001 commented 10 years ago

Thank you for posting the actual error. I thought it was an issue with the CoffeeScript Previewing, however this is actually an issue with the analytics-node library using unsafe-eval. I can now resolve the actual problem.

Glavin001 commented 10 years ago

Published fix to v0.13.2

deankarn commented 10 years ago

Perfect! work like a charm now, thanks again for your quick response.

Glavin001 commented 10 years ago

Glad to hear it worked! You're very welcome. Thank you for reporting this issue. Let me know if there's anything else I can do.