diff options
author | Anton Khirnov <anton@khirnov.net> | 2022-09-15 11:14:53 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2022-09-15 11:14:53 +0200 |
commit | 51461609a05743adae7018932a986e3f4455f55e (patch) | |
tree | 8cd563f6dfe2ec378e1b23b3a93e56ffa81d754d | |
parent | 548e62d41098579a82178bbcc74071998b573aca (diff) |
Handle map characters outside of the alphabet.
Can happen when importing maps from elsewhere.
-rwxr-xr-x | fshare.py | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -179,7 +179,13 @@ class URLMap: data = [l.strip().split() for l in self._file.readlines()] self._short_to_full = dict(data) self._full_to_short = dict(((b, a) for (a, b) in data)) - self._next_id = self._enc.decode_url(data[-1][0]) if len(data) else 0 + + try: + self._next_id = self._enc.decode_url(data[-1][0]) + except (IndexError, ValueError): + # data is empty or the mapping uses characters not in alphabet + self._next_id = 0 + except: self.close() raise |