ashleydw / lightbox

A lightbox gallery plugin for Bootstrap
http://ashleydw.github.io/lightbox
MIT License
1.85k stars 1.3k forks source link

Lightbox generates CSP errors for sites that block inline-styles #256

Closed april closed 7 years ago

april commented 7 years ago

So, you're experiencing a problem?

The current version of lightbox generates a CSP (Content Security Policy) error when sites are set to block 'unsafe-inline' styles. This is because there are a couple pieces of the code that are setting styles directly on elements via a style tag.

If you really do think you have a bug, please:

This is the piece of code that causes the problem:

let header = `<div class="modal-header"${this._config.title || this._config.alwaysShowClose ? '' : ' style="display:none"'}>`+(this._isBootstrap3 ? btn+h4 : h4+btn)+`</div>`;

(and also footer)

april commented 7 years ago

I think you also make a few calls into .css() as well. For the piece of code above, I think you can just use class="hide", since it's part of Bootstrap. For calls into csp() it might be a bit more complicated, but not too tricky I don't think.