Skip to content

Commit

Permalink
Add workaround for BrowserWorks/Waterfox#1780
Browse files Browse the repository at this point in the history
  • Loading branch information
zakius committed Jan 16, 2021
1 parent b08a186 commit b7ddd47
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 73 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Extension is available in following repositories:

## Known issues:

- in Firefox builds prior to `2017-08-09` and derivatives there's issue with CSP that causes extension to fail all requests following the one that got blocked, the only way to recover is to reload extension but it will happen again next time given source is loaded, issue reported to Waterfox #1780 in hope the fix will get ported to Classic
- in Firefox builds prior to `2017-08-09` and derivatives there's issue with CSP that causes extension to fail all requests following the one that got blocked, the only way to recover is to reload extension but it will happen again next time given source is loaded, issue reported to Waterfox MrAlex94/Waterfox#1780 in hope the fix will get ported to Classic - in the meantime attempted to work around this bug by removing CSP header from data loaded by the extension

## For developers

Expand Down
146 changes: 74 additions & 72 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,75 +1,77 @@
{
"name": "Smart RSS",
"developer": {
"name": "zakius",
"url": ""
},
"description": "RSS Reader",
"manifest_version": 2,
"version": "2.21.1",
"background": {
"page": "index.html"
},
"permissions": [
"unlimitedStorage",
"alarms",
"tabs",
"contextMenus",
"<all_urls>",
"*://*/*",
"https://code.fb.com/*",
"https://dev.opera.com/*"
],
"chromium_permissions": [
"unlimitedStorage",
"contextMenus",
"alarms",
"tabs",
"<all_urls>"
],
"content_security_policy": "default-src * 'self' data: 'unsafe-inline'; script-src 'self'; style-src * 'self' data: 'unsafe-inline'; img-src * 'self' data:; object-src 'self'",
"chromium_content_security_policy": "script-src 'self'; object-src 'self'",
"browser_action": {
"default_title": "Smart RSS",
"default_icon": {
"19": "images/reload_anim_1.png"
}
},
"content_scripts": [
{
"matches": [
"name": "Smart RSS",
"developer": {
"name": "zakius",
"url": ""
},
"description": "RSS Reader",
"manifest_version": 2,
"version": "2.21.1",
"background": {
"page": "index.html"
},
"permissions": [
"unlimitedStorage",
"alarms",
"tabs",
"contextMenus",
"<all_urls>",
"*://*/*",
"https://code.fb.com/*",
"https://dev.opera.com/*",
"webRequest",
"webRequestBlocking"
],
"chromium_permissions": [
"unlimitedStorage",
"contextMenus",
"alarms",
"tabs",
"<all_urls>"
],
"run_at": "document_end",
"js": [
"rssDetector/scan.js"
]
}
],
"options_ui": {
"page": "options.html",
"open_in_tab": true
},
"icons": {
"19": "images/icon19-arrow-orange.png",
"48": "images/48-inverted-round.png",
"64": "images/64-inverted-round.png",
"96": "images/96-inverted-round.png",
"128": "images/128-inverted-round.png"
},
"commands": {
"_execute_browser_action": {
"suggested_key": {
"windows": "Ctrl+Shift+R",
"mac": "Command+Shift+R",
"chromeos": "Ctrl+Shift+R",
"linux": "Ctrl+Shift+R"
}
}
},
"browser_specific_settings": {
"gecko": {
"id": "smart-rss@mozilla.firefox"
],
"content_security_policy": "default-src * 'self' data: 'unsafe-inline'; script-src 'self'; style-src * 'self' data: 'unsafe-inline'; img-src * 'self' data:; object-src 'self'",
"chromium_content_security_policy": "script-src 'self'; object-src 'self'",
"browser_action": {
"default_title": "Smart RSS",
"default_icon": {
"19": "images/reload_anim_1.png"
}
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"run_at": "document_end",
"js": [
"rssDetector/scan.js"
]
}
],
"options_ui": {
"page": "options.html",
"open_in_tab": true
},
"icons": {
"19": "images/icon19-arrow-orange.png",
"48": "images/48-inverted-round.png",
"64": "images/64-inverted-round.png",
"96": "images/96-inverted-round.png",
"128": "images/128-inverted-round.png"
},
"commands": {
"_execute_browser_action": {
"suggested_key": {
"windows": "Ctrl+Shift+R",
"mac": "Command+Shift+R",
"chromeos": "Ctrl+Shift+R",
"linux": "Ctrl+Shift+R"
}
}
},
"browser_specific_settings": {
"gecko": {
"id": "smart-rss@mozilla.firefox"
}
}
}
}
}
37 changes: 37 additions & 0 deletions src/scripts/bgprocess/bg.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,43 @@ define([
});
createLinksMenu();


if (typeof browser !== 'undefined') {
browser.runtime.getBrowserInfo().then((info) => {
if (info.name !== 'Waterfox') {
return;
}
if (info.version.split('.')[0] !== 56) {
return;
}

const onHeadersReceived = function (details) {
details.tabId === -1;

for (let i = 0; i < details.responseHeaders.length; i++) {
if (details.responseHeaders[i].name.toLowerCase() === 'content-security-policy') {
details.responseHeaders[i].value = '';
}
}

return {
responseHeaders: details.responseHeaders
};
};


const onHeaderFilter = {
urls: ['*://*/*'],
types: ['main_frame', 'sub_frame', 'other', 'object_subrequest', 'xmlhttprequest'],
tabId: -1
};
chrome.webRequest.onHeadersReceived.addListener(
onHeadersReceived, onHeaderFilter, ['blocking', 'responseHeaders']
);
});
}


/**
* Set icon
*/
Expand Down

0 comments on commit b7ddd47

Please sign in to comment.