Improve timezone resiliency #20

Open
opened 2025-04-30 19:35:56 +02:00 by Georg · 0 comments
Owner

Currently it is possible for a user to set a time zone like “EST” which pytz’s unpickler() function would only accept if utcoffset=None is passed as well.

This effectively corrupts the database:

>>> with open('/tmp/Tripsit.db', 'rb') as f:
...   data = pickle.load(f)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/opt/limnoria/katyusha/.local/lib/python3.6/site-packages/pytz/__init__.py", line 307, in _p
    return unpickler(*args)
  File "/opt/limnoria/katyusha/.local/lib/python3.6/site-packages/pytz/tzinfo.py", line 552, in unpickler
    return tz._tzinfos[(utcoffset, dstoffset, tzname)]
AttributeError: 'EST' object has no attribute '_tzinfos'

The plugin should only accept timezones which don’t corrupt the database as it is inconvenient for an administrator having to repair the database (which is possible using a patched pytz).

Currently it is possible for a user to set a time zone like "EST" which pytz's `unpickler()` function would only accept if `utcoffset=None` is passed as well. This effectively corrupts the database: ``` >>> with open('/tmp/Tripsit.db', 'rb') as f: ... data = pickle.load(f) ... Traceback (most recent call last): File "<stdin>", line 2, in <module> File "/opt/limnoria/katyusha/.local/lib/python3.6/site-packages/pytz/__init__.py", line 307, in _p return unpickler(*args) File "/opt/limnoria/katyusha/.local/lib/python3.6/site-packages/pytz/tzinfo.py", line 552, in unpickler return tz._tzinfos[(utcoffset, dstoffset, tzname)] AttributeError: 'EST' object has no attribute '_tzinfos' ``` The plugin should only accept timezones which don't corrupt the database as it is inconvenient for an administrator having to repair the database (which is possible using a patched pytz).
Sign in to join this conversation.
No description provided.