File torbrowser-launcher-version-check-fix.patch of Package torbrowser-launcher.14247
From 070a5f40af7c93d39bddfc5aa382469ce97dfd5b Mon Sep 17 00:00:00 2001
From: Robert Sacks <robert@rmsacks.com>
Date: Wed, 23 Sep 2020 00:42:50 -0400
Subject: [PATCH] Use better version string comparison
Currently, this function compares raw version strings such as "7.5.2"
and "9.6" to find the newer version. This worked fine until Tor Browser
version 10 was released and "10.0" is no longer considered larger than
"7.5.2" by this function. This commit changes the function to split the
raw strings on periods and compares the corresponding tuples, such as
(7, 5, 2) and (10, 0). While this does not cover all edge cases, it
should work better for these purposes. It is also simple and avoids
adding an extra dependency compared to other options.
Fixes #498
---
torbrowser_launcher/launcher.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/torbrowser_launcher/launcher.py b/torbrowser_launcher/launcher.py
index efcd1c8..715ef20 100644
--- a/torbrowser_launcher/launcher.py
+++ b/torbrowser_launcher/launcher.py
@@ -417,7 +417,10 @@ def check_min_version(self):
installed_version = line.split()[2].decode()
break
- if self.min_version <= installed_version:
+ def version_tuple(v):
+ return tuple(map(int, v.split(".")))
+
+ if version_tuple(self.min_version) <= version_tuple(installed_version):
return True
return False