Should Comply to Allow CSP policies (actually this forces the use of unsafe-inline) #1565
Closed
Description
Prerequisites
- I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
- The issue still exists against the latest
master
branch of bootstrap-fileinput. - This is not an usage question. I confirm having read the plugin documentation and demos.
- This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
- I have attempted to find the simplest possible steps to reproduce the issue.
- I have included a failing test as a pull request (Optional).
Steps to reproduce the issue
- Set CSP policies to disallow inline (« style-src »)
This is a general issue. It would be necessary to rework things.
There is no quick workaround as I see it.
It should use CSSOM ( $(element).css('prop', value))
https://stackoverflow.com/a/29089970/4355295
The actual system is a tree of templates to display things with a replace function to set values.
The solution would be loaded items with no style attr, and then set them using CSSOM.
I have identified 3 entries to fix there 👍
- tZoomCache ( style="display:none" ), easy to fix using a class like
d-none
- tProgress style="width" to set the progress width
return tmplt.setTokens({
'previewId': id,
'caption': caption,
'title': title,
'alt': alt,
'frameClass': css,
'type': self._getFileType(ftype),
'fileindex': ind,
'fileid': fileId || '',
'typeCss': typeCss,
'footer': footer,
'data': d,
'template': templ || cat,
'style': styleAttribs ? 'style="' + styleAttribs + '"' : ''
});
This last one need to be investigated.
I could try to propose a PR if this interests you, and if you are not planning a rewrite of this lib actually.
I crossed this issue working on my project.
These are relevant CSP HTTP headers I am using
Content-Security-Policy: default-src 'self' 'nonce-apwNAzO8atqpImT5'; script-src 'unsafe-eval' 'nonce-apwNAzO8atqpImT5'; frame-src 'self' https://docs.google.com; style-src 'nonce-apwNAzO8atqpImT5'; object-src 'none'; base-uri 'none'; report-uri /omenfilemanager/csp/report