Skip to content

Commit

Permalink
Fully block all HTTP requests in the reader
Browse files Browse the repository at this point in the history
  • Loading branch information
AbeJellinek authored and dstillman committed Feb 24, 2024
1 parent 6095ee9 commit 52856ae
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions chrome/content/zotero/xpcom/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import FilePicker from 'zotero/modules/filePicker';

const { BlockingObserver } = ChromeUtils.import("chrome://zotero/content/BlockingObserver.jsm");

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length
const ARRAYBUFFER_MAX_LENGTH = Services.appinfo.is64Bit
? Math.pow(2, 33)
Expand Down Expand Up @@ -193,6 +195,13 @@ class ReaderInstance {
Zotero.Reader._dispatchEvent(data);
});

this._blockingObserver = new BlockingObserver({
shouldBlock(uri) {
return uri.scheme === 'http' || uri.scheme === 'https';
}
});
this._blockingObserver.register(this._iframe);

this._internalReader = this._iframeWindow.wrappedJSObject.createReader(Components.utils.cloneInto({
type: this._type,
data,
Expand Down Expand Up @@ -552,6 +561,9 @@ class ReaderInstance {
this._prefObserverIDs.forEach(id => Zotero.Prefs.unregisterObserver(id));
}
this._flushState();
if (this._blockingObserver) {
this._blockingObserver.unregister(this._iframe);
}
}

get itemID() {
Expand Down

0 comments on commit 52856ae

Please sign in to comment.