From 63969fb0f481b739479993cb3b8c49248a263e8e Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Wed, 17 Aug 2011 18:34:10 +0200 Subject: White-list accepted tag families: 'exif', 'iptc', 'xmp'. Any other family will raise a KeyError. --- src/pyexiv2/metadata.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pyexiv2/metadata.py b/src/pyexiv2/metadata.py index 57c0263..e8ef875 100644 --- a/src/pyexiv2/metadata.py +++ b/src/pyexiv2/metadata.py @@ -205,9 +205,9 @@ class ImageMetadata(MutableMapping): :raise KeyError: if the tag doesn't exist """ family = key.split('.')[0].lower() - try: + if family in ('exif', 'iptc', 'xmp'): return getattr(self, '_get_%s_tag' % family)(key) - except AttributeError: + else: raise KeyError(key) def _set_exif_tag(self, key, tag_or_value): @@ -267,9 +267,9 @@ class ImageMetadata(MutableMapping): :raise KeyError: if the key is invalid """ family = key.split('.')[0].lower() - try: + if family in ('exif', 'iptc', 'xmp'): return getattr(self, '_set_%s_tag' % family)(key, tag_or_value) - except AttributeError: + else: raise KeyError(key) def _delete_exif_tag(self, key): @@ -326,9 +326,9 @@ class ImageMetadata(MutableMapping): :raise KeyError: if the tag with the given key doesn't exist """ family = key.split('.')[0].lower() - try: + if family in ('exif', 'iptc', 'xmp'): return getattr(self, '_delete_%s_tag' % family)(key) - except AttributeError: + else: raise KeyError(key) def __iter__(self): -- cgit