question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Requires csp policy to allow "data:" because of the two background-image urls used for hover and active buttons.

See original GitHub issue

Sweetalert2 is great, but it uses some background-image data URLs to darken the button backgrounds on hover and when active:

.swal2-popup .swal2-actions:not(.swal2-loading) .swal2-styled:hover {
   background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGNikAQAACIAHF/uBd8AAAAASUVORK5CYII="); }
.swal2-popup .swal2-actions:not(.swal2-loading) .swal2-styled:active {
   background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGNiMAYAADwANpiOMBYAAAAASUVORK5CYII="); }

The upshot of this is that it requires the contentSecurityPolicy header to explicitly allow data: for the img-src policy. Is there any chance you would consider implementing a different way of darkening the images? I am worried about the implications of allowing data: for the img-src policy, for instance:

https://security.stackexchange.com/questions/94993/is-including-the-data-scheme-in-your-content-security-policy-safe/95011#95011

Maybe I am being too paranoid but wanted to raise the issue that using sweetalert2 requires a potential change to the content security policy header.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
acupofjosecommented, Feb 3, 2018

Thoughts?

.swal2-popup button.swal2-styled {
  position: relative;
}

.swal2-popup button.swal2-styled:hover:after,
.swal2-popup button.swal2-styled:active:after {
  position: absolute;
  content: "";
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.15);
}

Demo: https://jsfiddle.net/kxxc7kxh/1/

0reactions
szm1commented, Feb 16, 2018

No worries, thanks for fixing! Awesome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content security policy blocking remote CSS background image
I assume it doesn't like url(... , but the CSP spec doesn't seem to consider url() a scheme so I can't see what...
Read more >
Using Content Security Policy (CSP) to Secure Web Applications
This article shows how to use CSP headers to protect websites against XSS attacks and other attempts to bypass same-origin policy.
Read more >
Third party CSS is not safe | Tan Li Hau
Recently, I read Jake Archibald's "Third party CSS is not safe", and it has a lot to say about why 3rd party CSS...
Read more >
Creating Content - Oracle Help Center
Open the first guide (from which you want to link) in the editor; select the step after which the second guide should launch...
Read more >
Microsoft Edge Browser Policy Documentation
You can use these policies to configure how Microsoft Edge runs in your ... AutomaticDownloadsAllowedForUrls, Allow multiple automatic ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found