Skip to content

Should Comply to Allow CSP policies (actually this forces the use of unsafe-inline) #1565

Closed
@Kwaadpepper

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

  1. 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.

Capture d’écran de 2020-05-27 12-55-58

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

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions