diff --git a/lib/core/convert.py b/lib/core/convert.py index f3927e60d..ec6ed2015 100644 --- a/lib/core/convert.py +++ b/lib/core/convert.py @@ -125,6 +125,9 @@ def _serializeEncode(value): if isinstance(value, decimal.Decimal): return {_SERIALIZE_TAG: "dec", "v": getUnicode(value)} + if isinstance(value, (datetime.datetime, datetime.time)) and value.tzinfo is not None: + return getUnicode(value) # Note: time zone aware value (e.g. from '-d' connector) kept as displayed, as an arbitrary tzinfo can't be rebuilt + if isinstance(value, datetime.datetime): return {_SERIALIZE_TAG: "dt", "v": [value.year, value.month, value.day, value.hour, value.minute, value.second, value.microsecond]} diff --git a/lib/core/settings.py b/lib/core/settings.py index ccaea017a..b067c067e 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -19,7 +19,7 @@ from lib.core.enums import OS from thirdparty import six # sqlmap version (...) -VERSION = "1.10.11.3" +VERSION = "1.10.11.4" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) diff --git a/tests/test_serialize.py b/tests/test_serialize.py index fb7b72bcb..17b163e26 100644 --- a/tests/test_serialize.py +++ b/tests/test_serialize.py @@ -259,6 +259,19 @@ class TestDbmsScalars(unittest.TestCase): self.assertEqual(restored, value) self.assertIs(type(restored), type(value)) + def test_timezone_aware_kept_as_displayed(self): + # Note: a resumed '-d' session used to drop the offset (e.g. '+05:30'), as only naive fields got stored + class _Offset(datetime.tzinfo): + def utcoffset(self, dt): + return datetime.timedelta(hours=5, minutes=30) + + def dst(self, dt): + return datetime.timedelta(0) + + for value in (datetime.datetime(2024, 1, 2, 3, 4, 0, tzinfo=_Offset()), datetime.time(3, 4, 0, tzinfo=_Offset())): + self.assertEqual(rt(value), getUnicode(value)) + self.assertTrue(rt(value).endswith("+05:30")) + class TestRealSessionObjects(unittest.TestCase): # the exact shapes written with serialize=True across the codebase