[tor-commits] [meek/webextension] Cancel onBeforeSendHeaders in case of an exception.
dcf at torproject.org
dcf at torproject.org
Sat Mar 30 19:36:56 UTC 2019
commit b055968d6b845e20b2b8185354695856375d635b
Author: David Fifield <david at 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.
More information about the tor-commits
mailing list