]> git.phdru.name Git - extfs.d.git/commitdiff
Feat(torrent): Try harder to guess encoding master
authorOleg Broytman <phd@phdru.name>
Sat, 14 Oct 2023 14:01:59 +0000 (17:01 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 15 Oct 2023 20:38:52 +0000 (23:38 +0300)
torrent

diff --git a/torrent b/torrent
index bd5ff13f7db394d4b77329a278afed1f2bbd5ccb..a0f827ef91f7ad213d7ab70445e9ef0e54e6175a 100755 (executable)
--- a/torrent
+++ b/torrent
@@ -318,7 +318,12 @@ def decode_torrent():
         elif codepage:
             encoding = codepage.decode('ascii')
         else:
-            encoding = 'ascii'
+            for encoding in ('ascii', 'utf-8', default_encoding):
+                try:
+                    return decode_dict(torrent, encoding)
+                except UnicodeDecodeError:
+                    pass
+            torrent_error('UnicodeDecodeError')
         return decode_dict(torrent, encoding)
 
     return torrent