From 3d0e6aa4b7c484e4caacf1281ceff168b53d8d63 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Wed, 7 Dec 2016 17:59:11 -0800 Subject: [PATCH] add test case for spaces in datetime... The real bug is that strptime doesn't error out, but it's likely buggy on more than just MacOSX, so just catch it here. --- pasn1.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pasn1.py b/pasn1.py index fb92b1e..fa2c846 100644 --- a/pasn1.py +++ b/pasn1.py @@ -386,6 +386,10 @@ class ASN1Coder(object): if ts[-1] != 'Z': raise ValueError('last character must be Z') + # Real bug is in strptime, but work around it here. + if ' ' in data: + raise ValueError('no spaces are allowed') + if '.' in ts: fstr = '%Y%m%d%H%M%S.%fZ' if ts.endswith('0Z'): @@ -511,6 +515,7 @@ class TestCode(unittest.TestCase): 'e007020101020102020105040673646c6b666a', # dict short value still valid '181632303136303231353038343031362e3539303839305a', #datetime w/ trailing zero '181632303136303231373136343034372e3035343433367a', #datetime w/ lower z + '181632303136313220383031303933302e3931353133385a', #datetime w/ space ]: self.assertRaises(ValueError, loads, v.decode('hex'))