From b85477787dddaf1e485ac7511059b578ae155b32 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Tue, 25 Feb 2020 16:46:21 +0100 Subject: [PATCH] Workaround for Tor utf8 cookie file path encoding bug on Windows --- src/Tor/TorManager.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Tor/TorManager.py b/src/Tor/TorManager.py index 48db2752..7e5c8bb0 100644 --- a/src/Tor/TorManager.py +++ b/src/Tor/TorManager.py @@ -152,6 +152,9 @@ class TorManager(object): res_auth = self.send('AUTHENTICATE "%s"' % config.tor_password, conn) elif cookie_match: cookie_file = cookie_match.group(1).encode("ascii").decode("unicode_escape") + if not os.path.isfile(cookie_file) and self.tor_process: + # Workaround for tor client cookie auth file utf8 encoding bug (https://github.com/torproject/stem/issues/57) + cookie_file = os.path.dirname(self.tor_exe) + "\\data\\control_auth_cookie" auth_hex = binascii.b2a_hex(open(cookie_file, "rb").read()) res_auth = self.send("AUTHENTICATE %s" % auth_hex.decode("utf8"), conn) else: