isamert / scli

a simple terminal user interface for signal messenger (using signal-cli)
GNU General Public License v3.0
439 stars 40 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbd in position #145

Closed javydekoning closed 2 years ago

javydekoning commented 2 years ago

scli won't start due to UnicodeDecodeError. One of my group-cache files cannot be decoded.

 ./scli --ver
scli 0.6.4-9-g2b1670b

Output:

Traceback (most recent call last):
  File "/Users/me/github/scli/./scli", line 4461, in <module>
    main()
  File "/Users/me/github/scli/./scli", line 4443, in main
    coord = Coordinate()
  File "/Users/me/github/scli/./scli", line 3806, in __init__
    self._contacts = Contacts(sigdata)
  File "/Users/me/github/scli/./scli", line 1041, in __init__
    self.reload()
  File "/Users/me/github/scli/./scli", line 1044, in reload
    indivs_dicts, groups_dicts = self._sigdata.parse_data_file()
  File "/Users/me/github/scli/./scli", line 885, in parse_data_file
    cached_name = self._get_group_v2_cache_name(group_id)
  File "/Users/me/github/scli/./scli", line 923, in _get_group_v2_cache_name
    grp_name = cache[2:name_end].decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbd in position 21: invalid start byte

Some extra info:

signal-cli -u '+mynumber' listGroups
Id: <the_group_id> Name: P  Active: true Blocked: false

(yes, the groupname really is just P, as I thought it might be due to some unknown character and renamed the group to P.

print(group_id)
<the_group_id>
print(cache[2:name_end])
b'P"\x00*\x06\x08\x02\x10\x02\x18\x040\x01:6\n\x10P\xd9\xaf\xbdN\xd1I\xf0\xa9zw\xe1\xf3\x86\xd8\x07\x10\x02\x1a N\x9f\xa1\xdf\xdfnb=iz\xde\x1e\xea\xed\xc0t\xa4\nG\xfc\x87\xdev+ \x90x.\xc0\xe3\xc5t:6\n\x10\x13\x81\xfc\x7f\x8b6E\xaa\xb7\x87\xc7\xa0\xccA87\x10\x01\x1a \xb1\xa3j\x15\xb54\\\xf0E\x114\x02\xef\x11SVR\xd1#)>\x9b'

As a workaround I changed _get_group_v2_cache_name like:

         try:
            grp_name = cache[2:name_end].decode()
            return grp_name
        except:
            return 'unknown-group-name'
exquo commented 2 years ago

That's a bug, thanks for reporting! I'll push a fix to master shortly.