Skip to content

Commit e28cf61

Browse files
author
Roland Hedberg
committed
Merge branch 'master' of github.com:rohe/pysaml2
2 parents c5aa4a2 + a8c5cc5 commit e28cf61

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/saml2/httpbase.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,20 @@ def _since_epoch(cdate):
6767
if len(cdate) < 5:
6868
return utc_now()
6969

70-
cdate = cdate[5:]
70+
cdate = cdate[5:] # assume short weekday, i.e. do not support obsolete RFC 1036 date format
7171
try:
72-
t = time.strptime(cdate, "%d-%b-%Y %H:%M:%S %Z")
72+
t = time.strptime(cdate, "%d-%b-%Y %H:%M:%S %Z") # e.g. 18-Apr-2014 12:30:51 GMT
7373
except ValueError:
74-
t = time.strptime(cdate, "%d-%b-%y %H:%M:%S %Z")
74+
try:
75+
t = time.strptime(cdate, "%d-%b-%y %H:%M:%S %Z") # e.g. 18-Apr-14 12:30:51 GMT
76+
except ValueError:
77+
try:
78+
t = time.strptime(cdate, "%d %b %Y %H:%M:%S %Z") # e.g. 18 Apr 2014 12:30:51 GMT
79+
except ValueError:
80+
raise Exception, 'ValueError: Date "{0}" does not match any of '.format(cdate) + \
81+
'"%d-%b-%Y %H:%M:%S %Z", ' + \
82+
'"%d-%b-%y %H:%M:%S %Z", ' + \
83+
'"%d %b %Y %H:%M:%S %Z".'
7584
#return int(time.mktime(t))
7685
return calendar.timegm(t)
7786

0 commit comments

Comments
 (0)