Skip to content

gh-152957: Raise ValueError for invalid <date> in plistlib#152958

Open
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:fix-plistlib-invalid-date
Open

gh-152957: Raise ValueError for invalid <date> in plistlib#152958
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:fix-plistlib-invalid-date

Conversation

@tonghuaroot

Copy link
Copy Markdown
Contributor

_date_from_string in Lib/plistlib.py did _dateParser.match(s).groupdict().
On a non-matching <date> value match() returns None, so .groupdict()
fails with AttributeError; on a partial match (the regex allows year-only and
year-month) too few fields reach datetime.datetime(*lst), which fails with
TypeError. Both now raise ValueError, matching the sibling <integer> and
<real> elements. The binary plist format decodes dates with struct.unpack
and is unaffected.

_date_from_string did _dateParser.match(s).groupdict(). On a non-matching
value match() returns None (AttributeError); on a partial match (the regex
allows year-only and year-month) too few fields reach datetime.datetime(*lst)
(TypeError). Both now raise ValueError, matching the sibling <integer> and
<real> elements. The binary plist format decodes dates with struct.unpack and
is unaffected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant