diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2011-08-17 18:34:10 +0200 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2011-08-17 18:34:10 +0200 |
commit | 63969fb0f481b739479993cb3b8c49248a263e8e (patch) | |
tree | 7c0dfc1679fec55d767585978ee690400365a02b /src | |
parent | fa8a2a497ed8bf62bd53ff6198da62346c50af08 (diff) | |
download | pyexiv2-63969fb0f481b739479993cb3b8c49248a263e8e.tar.gz |
White-list accepted tag families: 'exif', 'iptc', 'xmp'.
Any other family will raise a KeyError.
Diffstat (limited to 'src')
-rw-r--r-- | src/pyexiv2/metadata.py | 12 |
1 files 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): |