CSP: Hide wrapper span with class instead of style attribute#581
CSP: Hide wrapper span with class instead of style attribute#581JohanWinther wants to merge 3 commits intortfeldman:masterfrom
Conversation
CSP nonces need to be added to any elements with a style attribute
|
With this patch, I'm still seeing the csp errors in console of Safari, Firefox, Chrome. I believe for |
|
Oh, so there's no way to use inline style attributes with nonces? Reference: https://content-security-policy.com/examples/allow-inline-style/ (the section about inline style attribute). |
I'm vendoring this repo and patching it :-/ instead of explaining "unsafe-hashes" to whom it may concern 😆 |
|
I realised that perhaps the function can omit the style attribute if you use a nonce, so you will have to use the class to hide the span. I'm reopening this and then I'll push these changes. Edit: I still think for most users is easier to add unsafe-hashes rather than introducing a new stylesheet to the CSP, especially if you only use elm-css. |
|
@choonkeat
I saw that there is no nonce for the |
|> styleToDeclaration (getCssTemplate [ Css.display Css.none ]) styleWrapperClassnice solution!
yes, I have a quick patch for local use for now type Nonce
= Nonce String
noncedGlobal : Nonce -> List Snippet -> Html.Styled.Html msg
noncedGlobal (Nonce nonce) snippets =
snippets
|> Preprocess.stylesheet
|> Resolve.compile
|> VirtualDom.text
|> List.singleton
|> VirtualDom.node "style" [ VirtualDom.attribute "nonce" nonce ]
|> List.singleton
|> VirtualDom.node "span"
[ VirtualDom.attribute "class" "elm-css-style-wrapper"
]
|> VirtualDom.Styled.unstyledNodenot particularly joyful to have 2 |
CSP nonces need to be added to any elements with a style attribute
This PR fixes the issue found in #570 (comment)