-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content Security Policy blocks images loaded through url() #16
Comments
silverwind
changed the title
Content Security Policy blocks images loaded through Stylish for Chrome
Content Security Policy blocks images loaded through url()
Sep 1, 2014
Not sure it's a good idea to be messing with security headers... |
Yes, it's a sensitive topic. I'll have to explore if this would just affect stylish or more. Edit: Code for reference below. Regarding https://github.com/StylishThemes/GitHub-Dark/wiki/Image, my solution for now is to put the following code in //
// Disable CSP on GitHub
//
chrome.webRequest.onHeadersReceived.addListener(function(details) {
for (var i = 0; i < details.responseHeaders.length; i++) {
if (details.responseHeaders[i].name.toUpperCase() === 'CONTENT-SECURITY-POLICY') {
var begin = details.responseHeaders[i].value.split('img-src', 2);
var end = begin[1].split(';', 2);
details.responseHeaders[i].value = begin[0] + 'img-src \'self\' data: *;' + end[1];
console.log('New CSP should be... ' + details.responseHeaders[i].value);
}
}
return {
responseHeaders: details.responseHeaders
};
}, {
urls: [ '*://*.github.com/*' ],
types: [ 'main_frame', 'sub_frame', 'stylesheet', 'script', 'image', 'object', 'xmlhttprequest', 'other' ]
}, [ 'blocking', 'responseHeaders' ]);
console.log('background.js Event Page'); And in {
"permissions": [
"webRequest",
"webRequestBlocking"
]
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Images loaded through an userstyle are subject to the CSP of the styled domain in Chrome. In contrast, Stylish for Firefox loads violating images just fine. I wonder if you could change the way the content is loaded in Chrome, or if this an issue I should bring up to the Chromium team.
In our case, we're loading images from
github.io
ongithub.com
. Here' the CSP errror:Related issues:
StylishThemes/GitHub-Dark#164
StylishThemes/GitHub-Dark#166
The text was updated successfully, but these errors were encountered: