josdejong / josdejong/jsoneditor

Remove Data URLs from code

Open
#1,418 5 comments 0 reactions 0 assignees View on GitHub
feature help wanted
Dominant language
JavaScript
Stars
12.3k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

In this piece of code a [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) is used:

https://github.com/josdejong/jsoneditor/blob/e69a835f721bab6824b65f3d13717a20ff7d81f7/src/js/ace/theme-jsoneditor.js#L138

This requires applications using [Content Security Policy ](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) directives with full restrictions to allow `data:` as described [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/img-src) and [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/Sources).

https://security.stackexchange.com/questions/94993/is-including-the-data-scheme-in-your-content-security-policy-safe discusses if
`data:` is safe or not. One answer suggests it has never been proven to be unsafe, even though multiple articles mentions it is.

To be _better safe than sorry_ many applications forbid `data:` and only allow the `'self'` as the [CSP source](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/Sources).

Would it be possible to put the SVG in an external file and instead bundle it that way? I.e. as a real URL to the `.svg`. It's also nice in the sense that users can actually open the SVG in the src in this repo to see what it looks like 😄

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.