Skip to content

Conversation

@zepich
Copy link

@zepich zepich commented May 14, 2023

To use the Spectrum Color Picker on a website with a Content Security Policy header, the use of data: URIs in the CSS code is only allowed if the header contains the param data:.

While it's not that problematic compared to the unsafe-inline from pull request #41, it's still an insecure param, and you do not want it in your CSP header.

The solution for this is to use no data: URIs. A possible solution is to use an SVG sprite to have the background images with the best performance. This combines all SVGs into one file, but it's still possible to use the background image like before.

I've extracted the SVGs from the data: URIs and added them as files in the src/icons directory. Additionally, I've added grunt-svg-sprite as a dev dependency and added a new task build-sprite to combine the single SVGs into the sprite.

After that, I replaced the data: URIs in the CSS file to use the new SVG sprite.

Personal Note:
I've split these two CSP fixes into two pull requests because Spectrum does not require this one directly. I can overwrite the CSS rules in my project directly and solve it that way. It is impossible to do that with the JavaScript code without copying the files.

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

Successfully merging this pull request may close these issues.

1 participant