[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit b055968d6b845e20b2b8185354695856375d635b
Author: David Fifield <david@xxxxxxxxxxxxxxx>
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 mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits