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

Non-eval'ing method #6

Closed
tmcw opened this issue Aug 12, 2015 · 2 comments
Closed

Non-eval'ing method #6

tmcw opened this issue Aug 12, 2015 · 2 comments

Comments

@tmcw
Copy link
Contributor

tmcw commented Aug 12, 2015

The usage of the Function constructor in this module means that mapbox-gl-js upstream cannot satisfy the Content Security Policy unsafe-eval rule. For CSP-implementing sites, a non-eval'ing method would better.

@jfirebaugh
Copy link
Contributor

It would be possible to feature detect this and fall back to an interpreted implementation:

// Are we running under a CSP that forbids unsafe-eval?
try {
  new Function('');
  module.exports = require('./compiled'); // No; use fast eval'ing implementation
} catch (e) {
  module.exports = require('./interpreted); // Yes; use slower interpreted implementation
}

But it would be preferable not to introduce a performance variable and use a sufficiently well performing, eval-free implementation everywhere.

@jfirebaugh
Copy link
Contributor

Feature detecting probably spams CSP violation reports though, huh?

mourner added a commit that referenced this issue Jan 29, 2016
mourner added a commit that referenced this issue Jan 29, 2016
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

No branches or pull requests

2 participants