aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/pyexiv2.py5
-rw-r--r--unittest/xmp.py2
2 files changed, 4 insertions, 3 deletions
diff --git a/src/pyexiv2.py b/src/pyexiv2.py
index 8fa4a48..1b54782 100644
--- a/src/pyexiv2.py
+++ b/src/pyexiv2.py
@@ -483,7 +483,7 @@ class XmpTag(MetadataTag):
# strptime is not flexible enough to handle all valid Date formats, we use a
# custom regular expression
_time_zone_re = r'Z|((?P<sign>\+|-)(?P<ohours>\d{2}):(?P<ominutes>\d{2}))'
- _time_re = r'(?P<hours>\d{2}):(?P<minutes>\d{2})(:(?P<seconds>\d{2})(.(?P<decimal>\d+))?)?(?P<tzd>%s)' % _time_zone_re
+ _time_re = r'(?P<hours>\d{2})(:(?P<minutes>\d{2})(:(?P<seconds>\d{2})(.(?P<decimal>\d+))?)?(?P<tzd>%s))?' % _time_zone_re
_date_re = re.compile(r'(?P<year>\d{4})(-(?P<month>\d{2})(-(?P<day>\d{2})(T(?P<time>%s))?)?)?' % _time_re)
def __init__(self, key, name, label, description, type, values):
@@ -547,6 +547,9 @@ class XmpTag(MetadataTag):
except ValueError:
raise XmpValueError(value, xtype)
else:
+ if gd['minutes'] is None:
+ # Malformed time
+ raise XmpValueError(value, xtype)
if gd['seconds'] is not None:
seconds = int(gd['seconds'])
else:
diff --git a/unittest/xmp.py b/unittest/xmp.py
index d8293fa..da81e03 100644
--- a/unittest/xmp.py
+++ b/unittest/xmp.py
@@ -104,8 +104,6 @@ class TestXmpTag(unittest.TestCase):
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, '2009-10-32', xtype)
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, '2009-10-30T25:12Z', xtype)
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, '2009-10-30T23:67Z', xtype)
-
- # FIXME: the following test should not fail: having hours without minutes is not a valid syntax.
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, '2009-01-22T21', xtype)
def test_convert_to_python_integer(self):