mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
#1162477: accept '.' in addition to ':' when parsing time in date header.
Some non-compliant MUAs use '.'s, so by the Postel Principle we should accept them. Patch by Thomas Herve.
This commit is contained in:
parent
0cfc23762f
commit
accd1c040f
3 changed files with 18 additions and 0 deletions
|
@ -99,6 +99,14 @@ def parsedate_tz(data):
|
||||||
tss = '0'
|
tss = '0'
|
||||||
elif len(tm) == 3:
|
elif len(tm) == 3:
|
||||||
[thh, tmm, tss] = tm
|
[thh, tmm, tss] = tm
|
||||||
|
elif len(tm) == 1 and '.' in tm[0]:
|
||||||
|
# Some non-compliant MUAs use '.' to separate time elements.
|
||||||
|
tm = tm[0].split('.')
|
||||||
|
if len(tm) == 2:
|
||||||
|
[thh, tmm] = tm
|
||||||
|
tss = 0
|
||||||
|
elif len(tm) == 3:
|
||||||
|
[thh, tmm, tss] = tm
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -2328,6 +2328,13 @@ class TestMiscellaneous(TestEmailBase):
|
||||||
(2002, 4, 3, 14, 58, 26, 0, 1, -1, -28800))
|
(2002, 4, 3, 14, 58, 26, 0, 1, -1, -28800))
|
||||||
|
|
||||||
|
|
||||||
|
def test_parsedate_accepts_time_with_dots(self):
|
||||||
|
eq = self.assertEqual
|
||||||
|
eq(utils.parsedate_tz('5 Feb 2003 13.47.26 -0800'),
|
||||||
|
(2003, 2, 5, 13, 47, 26, 0, 1, -1, -28800))
|
||||||
|
eq(utils.parsedate_tz('5 Feb 2003 13.47 -0800'),
|
||||||
|
(2003, 2, 5, 13, 47, 0, 0, 1, -1, -28800))
|
||||||
|
|
||||||
def test_parsedate_acceptable_to_time_functions(self):
|
def test_parsedate_acceptable_to_time_functions(self):
|
||||||
eq = self.assertEqual
|
eq = self.assertEqual
|
||||||
timetup = utils.parsedate('5 Feb 2003 13:47:26 -0800')
|
timetup = utils.parsedate('5 Feb 2003 13:47:26 -0800')
|
||||||
|
|
|
@ -68,6 +68,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #1162477: Postel Principal adjustment to email date parsing: handle the
|
||||||
|
fact that some non-compliant MUAs use '.' instead of ':' in time specs.
|
||||||
|
|
||||||
- Issue #11131: Fix sign of zero in decimal.Decimal plus and minus
|
- Issue #11131: Fix sign of zero in decimal.Decimal plus and minus
|
||||||
operations when the rounding mode is ROUND_FLOOR.
|
operations when the rounding mode is ROUND_FLOOR.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue