Content security policy
See original GitHub issueSlick slider is not CSP compliant https://en.wikipedia.org/wiki/Content_Security_Policy
No fiddle because it requires server headers
Steps to reproduce the problem
- Enable CSP on your server
- Add slick
What is the expected behaviour?
Beautiful and safe website
What is observed behaviour?
CSP stopped execution because of this:
_.$slides.each(function(index, element) {
$(element)
.attr('data-slick-index', index)
.data('originalStyling', $(element).attr('style') || '');
});
if(_.options.rows > 1) {
originalSlides = _.$slides.children().children();
originalSlides.removeAttr('style');
_.$slider.empty().append(originalSlides);
}
if (_.$slides) {
_.$slides
.removeClass('slick-slide slick-active slick-center slick-visible slick-current')
.removeAttr('aria-hidden')
.removeAttr('data-slick-index')
.each(function(){
$(this).attr('style', $(this).data('originalStyling'));
});
- setting inline style!
More Details
- Which browsers/versions does it happen on? All browsers supporting CSP
- Which jQuery/Slick version are you using? Present in slick/slick.js in master branch
- Did this work before? Nope?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:17 (6 by maintainers)
Top Results From Across the Web
Content-Security-Policy Header CSP Reference & Examples
Content-Security-Policy is the name of a HTTP response header that modern browsers use to enhance the security of the document (or web page)....
Read more >Content Security Policy - Wikipedia
Content Security Policy (CSP) is a computer security standard introduced to prevent cross-site scripting (XSS), clickjacking and other code injection ...
Read more >Content security policy - web.dev
Content Security Policy can significantly reduce the risk and impact of cross-site scripting attacks in modern browsers.
Read more >What is Content Security Policy (CSP) | Header Examples
A Content Protection Policy (CSP) is a security standard that provides an additional layer of protection from cross-site scripting (XSS), clickjacking, ...
Read more >Content Security Policy Level 3 - W3C
This document defines Content Security Policy (CSP), a tool which developers can use to lock down their applications in various ways, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For literally everything having to do with dynamically positioning elements?
Whats the fix here? Sanitizing the originalStyling data ?