Fix export data#1532
Conversation
There was a problem hiding this comment.
I confirmed that the fix does indeed fix the issue on Chrome, and that the fix makes exporting work better on Firefox.
Unfortunately, I can't approve this until we find a workaround that doesn't require asking for the "downloads" permission, which, I just confirmed, disables Privacy Badger upon upgrade until the user grants Privacy Badger the additional permission:
|
To test adding additional permissions in Chrome, see Testing permission warnings in Chrome Extensions developer documentation. You can package our extension by running <?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='GET-THIS-ID-FROM-THE-CHROME-EXTENSIONS-PAGE-AFTER-DRAGGING-AND-DROPPING-THE-CRX'>
<updatecheck codebase='http://localhost:9999/privacy_badger-2017.7.25.crx' version='2017.7.25' />
</app>
</gupdate> |
|
The previous method also supports blobs and fixes the bug within chrome, but will not work in Firefox (bugzilla bug report). While I don't know the previous discussion around changing this specific code, I think adding this permission and as result, an automatic disabling of the extension will benefit the user in the long run. |
|
I don't think we should make users go through the disable-and-reenable process, which will result in losing a significant percentage of our userbase, unless we absolutely have to. This bug isn't high profile enough to warrant this step; there may yet be another workaround; PR #1462 should make the issue disappear for most people. |
I am not sure what you mean by this, could you elaborate please? |
|
Look at the latest commit, easier than me explaining it |
|
The code must switch to a blob, otherwise, the bug will keep creeping up. How chrome is coded, an url can only be a certain length, a blob will fix this. |
There was a problem hiding this comment.
Why do you say that the blob approach doesn't work in Firefox? I just tested the simplified code below on Firefox 54, and it seemed to work fine:
diff --git a/src/js/options.js b/src/js/options.js
index 2b82618..3dd8abc 100644
--- a/src/js/options.js
+++ b/src/js/options.js
@@ -183,24 +183,11 @@ function exportUserData() {
var a = document.createElement('a');
a.setAttribute('download', filename || '');
- if(chrome.runtime.getBrowserInfo){
- chrome.runtime.getBrowserInfo((info) => {
- if(info.name == "Firefox"){
- a.href = 'data:application/json;charset=utf-8,' + encodeURIComponent(mapJSON);
- a.dispatchEvent(new MouseEvent('click'));
- } else {
- var blob = new Blob([mapJSON], {type: 'application/json'}); // pass a useful mime type here
- a.href = URL.createObjectURL(blob);
- a.dispatchEvent(new MouseEvent('click'));
- URL.revokeObjectURL(blob);
- }
- });
- } else {
- var blob = new Blob([mapJSON], {type: 'application/json'}); // pass a useful mime type here
- a.href = URL.createObjectURL(blob);
- a.dispatchEvent(new MouseEvent('click'));
- URL.revokeObjectURL(blob);
- }
+ var blob = new Blob([mapJSON], {type: 'application/json'}); // pass a useful mime type here
+ a.href = URL.createObjectURL(blob);
+ a.dispatchEvent(new MouseEvent('click'));
+ URL.revokeObjectURL(blob);
+
});
}|
OK, I see, you linked to a Bugzilla issue above that itself is marked as a duplicate of https://bugzilla.mozilla.org/show_bug.cgi?id=1331176. It seems like downloading blobs doesn't work in Firefox 52, but might have been fixed some time since then. |
ghostwords
left a comment
There was a problem hiding this comment.
OK cool, let's merge this. Thank you for the fix! I'll add a note to remove the conditional once Firefox 52 goes away (it's currently the ESR version).
|
Merged in cde3fd8. Thanks again! |

Should fix #1318