commit b055968d6b845e20b2b8185354695856375d635b Author: David Fifield david@bamsoftware.com Date: Sat Mar 30 01:29:59 2019 -0600
Cancel onBeforeSendHeaders in case of an exception.
A typo during debugging cause the callback to crash and have no effect. --- webextension/browser/background.js | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/webextension/browser/background.js b/webextension/browser/background.js index d26b744..c47d06b 100644 --- a/webextension/browser/background.js +++ b/webextension/browser/background.js @@ -192,6 +192,11 @@ async function roundtrip(request) { } let browserHeaders = details.requestHeaders.filter(x => !(x.name.toLowerCase() in overrides)); return {requestHeaders: browserHeaders.concat(headers)}; + } catch (error) { + // In case of any error in the code above, play it safe and cancel + // the request. + console.log(`${browser.runtime.id}: error in onBeforeSendHeaders: ${error.message}`); + return {cancel: true}; } finally { // Now that the listener has been called, remove it and release the // lock to allow the next request to set a different listener.
tor-commits@lists.torproject.org