client_side_validations icon indicating copy to clipboard operation
client_side_validations copied to clipboard

'unsafe-eval' is not an allowed source of script

Open reckerswartz opened this issue 8 years ago • 12 comments

https://github.com/DavyJonesLocker/client_side_validations/blob/b393a8b419873f57c44c50624cee330268a013a6/coffeescript/rails.validations.coffee#L335 https://github.com/DavyJonesLocker/client_side_validations/blob/b393a8b419873f57c44c50624cee330268a013a6/coffeescript/rails.validations.coffee#L352

Above line of codes produces error

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.

helpful links:-

  • https://github.com/jamesallardice/jslint-error-explanations/blob/master/message-articles/function-constructor.md
  • http://jslint.fantasy.codes/the-function-constructor-is-eval

Environment

  • Version used: 11.1
  • Browser Name and version: Google Chrome Version 64.0.3282.140 (Official Build) (64-bit)
  • Operating System and version (desktop or mobile): Windows 10 Pro (64-bit)

reckerswartz avatar Feb 05 '18 11:02 reckerswartz

Hi,

thanks for reporting this

A PR would be hugely appreciated

tagliala avatar Feb 05 '18 11:02 tagliala

Will provide PR soon.

reckerswartz avatar Feb 06 '18 06:02 reckerswartz

@reckerswartz thanks

I gave a fast look, it doesn't look easy

By the way, there are three calls to Function that should be addressed.

The tokenizer seems the most complex. Fortunately, tokenizer option has been deprecated and we could bump the major version number and drop that feature

tagliala avatar Feb 06 '18 14:02 tagliala

@tagliala thanks for giving look to it. tokenizer will be droped in PR.

reckerswartz avatar Feb 06 '18 14:02 reckerswartz

you're welcome, thank you!

Please make sure yarn: lint and rake test:js pass.

Sorry, but the javascript part is poorly documented

tagliala avatar Feb 06 '18 14:02 tagliala

rake test:js Opening test app at http://localhost:4567 ... == Sinatra (v2.0.0) has taken the stage on 8080 for development with backup from Thin Thin web server (v1.7.2 codename Bachmanity) Maximum connections set to 1024 Listening on localhost:8080, CTRL+C to stop ERROR: no web browser detected

error on cloud9.

reckerswartz avatar Feb 14 '18 12:02 reckerswartz

@reckerswartz javascript unit tests require a real browser installed on the machine. The browser should be configured to open links from the command line

I need help on this: #591

tagliala avatar Feb 14 '18 13:02 tagliala

#591 I need some time to work on it and your help too 🆘 .

reckerswartz avatar Feb 14 '18 13:02 reckerswartz

@reckerswartz since that is not a priority, just check that rake test:js pass on your local machine then submit the PR

tagliala avatar Feb 14 '18 13:02 tagliala

Hey, can you tell me how can I regenerate javascript after modifying CoffeeScript?

reckerswartz avatar Apr 02 '18 00:04 reckerswartz

rake regenerate_javascript

if you run the test, the javascript will be automatically regenerated

tagliala avatar Apr 06 '18 08:04 tagliala

@reckerswartz I've implemented this in 191a265

tagliala avatar May 31 '18 13:05 tagliala