gatsby-plugin-csp icon indicating copy to clipboard operation
gatsby-plugin-csp copied to clipboard

CSP meta `content` is escaped

Open vcarl opened this issue 5 years ago • 2 comments

A production build puts the following in my head, as seen in curl:

<meta
  http-equiv="Content-Security-Policy"
  content="script-src &#x27;self&#x27; &#x27;sha256-<hash>&#x27; &#x27;<hash>&#x27;;"
/>

The 's are being escaped to &#x27;, which is breaking the CSP. It looks like createElement is escaping the HTML entities, so this meta tag might need to be constructed a different way.

vcarl avatar Sep 05 '19 18:09 vcarl

Been beating my head against this since opening the issue, am not sure what a fix is. I'm flat not able to get this package to work, I'm curious if there's a workaround I'm not seeing.

There's a confluence that makes this hard to fix: React doesn't support top-level dangerouslySetInnerHTML, and <meta> tags can't be nested within another tag. Drawing a blank on any other ways to ensure this property doesn't get escaped.

vcarl avatar Sep 05 '19 19:09 vcarl

Hi, I'm getting the same issue with the ' in the ' ' place.... any news about this issue?