[tor-commits] [meek/master] Cancel onBeforeSendHeaders in case of an exception.

dcf at torproject.org dcf at torproject.org
Wed Aug 28 05:59:18 UTC 2019


commit 73719bb3fddaaddffba7554adabff55bb5bd12ea
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 caused 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