Avoid traceback caused by bogus date input (issue3344)
authorChristian Ebert <blacktrash@gmx.net>
Fri, 10 Aug 2012 20:37:20 +0100
changeset 1141 4e2090ed2e72
parent 1140 689f8b6b711c
child 1142 2a75107bd979
child 1144 3222b5b93410
Avoid traceback caused by bogus date input (issue3344) Wrap datefilters which split date texts with util.parsedate. We do not abort, as the bogus date must have been given by the user.
hgkw/keyword.py
--- a/hgkw/keyword.py	Thu Oct 11 19:46:25 2012 +0200
+++ b/hgkw/keyword.py	Fri Aug 10 20:37:20 2012 +0100
@@ -117,7 +117,7 @@
 def utcdate(text):
     ''':utcdate: Date. Returns a UTC-date in this format: "2009/08/18 11:00:13".
     '''
-    return util.datestr((text[0], 0), '%Y/%m/%d %H:%M:%S')
+    return util.datestr((util.parsedate(text)[0], 0), '%Y/%m/%d %H:%M:%S')
 # date like in svn's $Date
 def svnisodate(text):
     ''':svnisodate: Date. Returns a date in this format: "2009-08-18 13:00:13
@@ -129,7 +129,7 @@
     ''':svnutcdate: Date. Returns a UTC-date in this format: "2009-08-18
     11:00:13Z".
     '''
-    return util.datestr((text[0], 0), '%Y-%m-%d %H:%M:%SZ')
+    return util.datestr((util.parsedate(text)[0], 0), '%Y-%m-%d %H:%M:%SZ')
 
 templatefilters.filters.update({'utcdate': utcdate,
                                 'svnisodate': svnisodate,