diff options
author | Alexey Dokuchaev <danfe@FreeBSD.org> | 2025-06-25 16:22:30 +0000 |
---|---|---|
committer | Alexey Dokuchaev <danfe@FreeBSD.org> | 2025-06-25 16:22:30 +0000 |
commit | a94b51d40765f0aedfca0069940d14db5068640e (patch) | |
tree | 30980dbde82f6e04e189b84dd711ebf69bd28599 /www/py-binarycookies/files/patch-src_binarycookies___deserialize.py | |
parent | www/py-freenit: update to 0.3.17 (diff) |
www/py-binarycookies: new port had been added (+)
Apple's Safari web browser binary cookies format (de)serializer
written in Python. Our modifications to the original sources
include the fix for "the year 2038 problem" on 32-bit systems,
Netscape traditional `cookies.txt' file format support, and use
of Pydantic V1 which does not pull in Rust unlike V2 which the
project needlessly assumes by default.
Diffstat (limited to 'www/py-binarycookies/files/patch-src_binarycookies___deserialize.py')
-rw-r--r-- | www/py-binarycookies/files/patch-src_binarycookies___deserialize.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/www/py-binarycookies/files/patch-src_binarycookies___deserialize.py b/www/py-binarycookies/files/patch-src_binarycookies___deserialize.py new file mode 100644 index 000000000000..3aec2539907c --- /dev/null +++ b/www/py-binarycookies/files/patch-src_binarycookies___deserialize.py @@ -0,0 +1,21 @@ +--- src/binarycookies/_deserialize.py.orig 2025-04-08 19:50:17 UTC ++++ src/binarycookies/_deserialize.py +@@ -1,6 +1,7 @@ + from datetime import datetime, timezone + from io import BytesIO + from struct import unpack ++from sys import maxsize + from typing import BinaryIO, List, Union + + from binarycookies.models import ( +@@ -28,7 +29,9 @@ def interpret_flag(flags: int) -> Flag: + + def mac_epoch_to_date(epoch: int) -> datetime: + """Converts a mac epoch time to a datetime object.""" +- return datetime.fromtimestamp(epoch + 978307200, tz=timezone.utc) ++ unix_epoch = epoch + 978307200 ++ if unix_epoch > maxsize: unix_epoch = maxsize ++ return datetime.fromtimestamp(unix_epoch, tz=timezone.utc) + + + def read_string(data: BytesIO, size: int) -> str: |