Add documentation to cover Firefox CSP SVG sprite blocking issue#34592
Add documentation to cover Firefox CSP SVG sprite blocking issue#34592chrisdavidmills merged 2 commits intomdn:mainfrom
Conversation
|
Preview URLs
External URLs (4)URL:
URL:
(comment last updated: 2024-07-03 11:30:33) |
pepelsbey
left a comment
There was a problem hiding this comment.
Looks good! I also double-checked how Firefox treats inlined sprites: it works! It might be an alternative solution if default-src 'none' is essential to keep. What do you think?
| </svg> | ||
| ``` | ||
|
|
||
| your SVG images will be blocked in Firefox if you have a `default-src 'none'` policy set. Firefox does not treat the SVG as an embedded image like other browsers do, therefore `img-src 'self'` will not allow them to be loaded. You need to use `default-src 'self'` if you want your external sprites to load in Firefox. See [bug 1773976](https://bugzilla.mozilla.org/show_bug.cgi?id=1773976) and [this CSP spec issue](https://github.com/w3c/webappsec-csp/issues/199) for more information. |
There was a problem hiding this comment.
| your SVG images will be blocked in Firefox if you have a `default-src 'none'` policy set. Firefox does not treat the SVG as an embedded image like other browsers do, therefore `img-src 'self'` will not allow them to be loaded. You need to use `default-src 'self'` if you want your external sprites to load in Firefox. See [bug 1773976](https://bugzilla.mozilla.org/show_bug.cgi?id=1773976) and [this CSP spec issue](https://github.com/w3c/webappsec-csp/issues/199) for more information. | |
| your SVG images will be blocked in Firefox if you have a `default-src 'none'` policy set. Firefox does not treat the SVG as an embedded image like other browsers do, therefore `img-src 'self'` will not allow them to be loaded. You need to use `default-src 'self'` if you want your external sprites to load in Firefox. Alternatively, you can inline the external sprite in the HTML page. See [bug 1773976](https://bugzilla.mozilla.org/show_bug.cgi?id=1773976) and [this CSP spec issue](https://github.com/w3c/webappsec-csp/issues/199) for more information. |
| </svg> | ||
| ``` | ||
|
|
||
| your SVG images will be blocked in Firefox if you have a `default-src 'none'` policy set. Firefox does not treat the SVG as an embedded image like other browsers do, therefore `img-src 'self'` will not allow them to be loaded. You need to use `default-src 'self'` if you want your external sprites to load in Firefox. |
There was a problem hiding this comment.
| your SVG images will be blocked in Firefox if you have a `default-src 'none'` policy set. Firefox does not treat the SVG as an embedded image like other browsers do, therefore `img-src 'self'` will not allow them to be loaded. You need to use `default-src 'self'` if you want your external sprites to load in Firefox. | |
| your SVG images will be blocked in Firefox if you have a `default-src 'none'` policy set. Firefox does not treat the SVG as an embedded image like other browsers do, therefore `img-src 'self'` will not allow them to be loaded. You need to use `default-src 'self'` if you want your external sprites to load in Firefox. Alternatively, you can inline the external sprite in the HTML page: | |
| ```html | |
| <body> | |
| <svg style="display: none"> | |
| <symbol id="icon" viewBox="0 0 24 24"> | |
| <path d="…"/> | |
| </symbol> | |
| </svg> | |
| … | |
| <svg> | |
| <use href="#icon"/> | |
| </svg> | |
| </body> | |
| ``` |
There was a problem hiding this comment.
Thanks @pepelsbey, this is great information. I have added it, but with slightly different wording/structure. My reasons:
- If we refer to external sprites being inlined, then I reckon people will nitpick that they are no longer external.
- I wanted to keep the bug/spec issue links attached to the bit about
default-src 'none'not working with external SVG sprites specifically.
Let me know if you think my additions read ok.
|
Awesome, I've put it live, as I don't think there is any point waiting. |
Description
This PR adds documentation covering the Firefox CSP
default-src 'none'SVG sprite blocking issue, documented by @pepelsbey at mdn/mdn-http-observatory#6.Motivation
Additional details
Related issues and pull requests