Feature request: Make vanilla-picker work with strict CSP header
See original GitHub issueHi! We are trying to migrate to a stricter Content-Security-Policy header. However, this currently does not work with vanilla-picker. The header we want to enforce is as follows:
Content-Security-Policy: img-src 'self' data:; default-src 'self'
This header causes dynamically injected <style>
elements to no longer work. They will be ignored and produce an error. Example in Chrome:
Refused to apply inline style because it violates the following Content Security Policy directive: "default-src 'self'". [...]
./node_modules/vanilla-picker/dist/vanilla-picker.mjs @ vanilla-picker.mjs:504
The way to fix this could be to add a new option externalCss: true
somewhere, which would prevent the dynamic <style>
injection. Additionally the user would have to manually import the CSS file using a <link>
element, or bundling it in webpack.
Note that directly applying styles to an element is not affected by this, e.g. uiSL.style.color = ...
still works fine.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Strict CSP - Content Security Policy
Strict CSP. Content Security Policy can help protect your application from XSS, but in order for it to be effective you need to...
Read more >Inline styles in Next 10 don't work with strict Content-Security ...
Create a Content-Security-Policy header in next.config.js with style-src: 'self'; (i.e. without unsafe-inline explicitly enabled) ...
Read more >Content Security Policy - OWASP Cheat Sheet Series
Using a header is the preferred way and supports the full CSP feature set. Send it in all HTTP responses, not just the...
Read more >How to protect PHP application from XSS attacks: CSP 3 nonce
Set the same string as a value to the Content-Security-Policy HTTP header. 1. Generate a random nonce string on each request. Let's create...
Read more >CSP: script-src - HTTP - MDN Web Docs - Mozilla
Alternatively, you can create hashes from your inline scripts. CSP supports sha256, sha384 and sha512. Content-Security-Policy: script-src ' ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Works perfectly now! Many thanks! ❤️
Ok, we’re getting closer 😃 Try
v2.12.1