-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Description
Describe the bug
When using SVG symbols (using data-fa-symbol) with the NPM package, inline styling is added here to hide the SVG symbol. However, with a strict Content Security Policy that doesn't include unsafe-inline for the style-src directive, the inline styles are rejected. This results in a CSP violation being reposted, and the SVG symbols not being correctly hidden.
To Reproduce
Set a CSP header of Content-Security-Policy: default-src 'self'; style-src 'self' and then try to use the SVG symbol feature.
Expected behavior
I suppose the best approach would be to add a css class to the symbol instead of the inline style here and add that class in styles.css. For those that haven't disabled config.autoAddCss, this should still work fine, and for those that have, at least it will provide a class that can be styled manually in the page CSS.
Screenshots
Example of rejected inline style and CSP violation:

Version and implementation
Version: @fortawesome/fontawesome-svg-core@^1.2.28
- SVG with JS
- Web Fonts with CSS
- SVG Sprites
- On the Desktop
Bug report checklist
- I have filled out as much of the above information as I can
- I have included a test case because my odds go way up that the team can fix this when I do
- I have searched for existing issues and to the best of my knowledge this is not a duplicate