mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Check argument type in get_date utility function before processing it
Sitemap plugin calls this method to convert `modified` metadate into datetime. Depending on the version of Pelican `modified` can be string or a datetime object. Therefore get_date should check for the type of argument otherwise Pelican fails with a critical error.
This commit is contained in:
parent
455c159b48
commit
5fbea6202f
1 changed files with 2 additions and 0 deletions
|
|
@ -180,6 +180,8 @@ def get_date(string):
|
|||
|
||||
If no format matches the given date, raise a ValueError.
|
||||
"""
|
||||
if isinstance(string, datetime):
|
||||
return string
|
||||
string = re.sub(' +', ' ', string)
|
||||
formats = [
|
||||
# ISO 8601
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue