This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author benhoyt
Recipients barry, benhoyt
Date 2021-09-18.22:35:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1632004553.3.0.0473045390855.issue45239@roundup.psfhosted.org>
In-reply-to
Content
In going through some standard library code, I found that the email.utils.parsedate_tz() function (https://docs.python.org/3/library/email.utils.html#email.utils.parsedate_tz) has a bug if the time value is in dotted format and has more than 2 dots in it, for example: "12.34.56.78". Per the docs, it should return None in the case of invalid input.

This is happening because in the case that handles the '.' separator (instead of the normal ':'), there's no else clause to return None when there's not 2 or 3 segments.

From https://github.com/python/cpython/blob/dea59cf88adf5d20812edda330e085a4695baba4/Lib/email/_parseaddr.py#L118-L132:

    if len(tm) == 2:
        [thh, tmm] = tm
        tss = '0'
    elif len(tm) == 3:
        [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
        # HERE: need "else: return None"
    else:
        return None

We simply need to include that additional "else: return None" block in the '.' handling case.

I'll submit a pull request that fixes this soon (and adds a test for this case).
History
Date User Action Args
2021-09-18 22:35:53benhoytsetrecipients: + benhoyt, barry
2021-09-18 22:35:53benhoytsetmessageid: <1632004553.3.0.0473045390855.issue45239@roundup.psfhosted.org>
2021-09-18 22:35:53benhoytlinkissue45239 messages
2021-09-18 22:35:53benhoytcreate