vorbis: empty string is not a valid Vorbis comment key

This commit is contained in:
Philipp Wolfer
2021-10-28 21:29:40 +02:00
parent 8154af24c9
commit 7a37e25152
2 changed files with 3 additions and 2 deletions

View File

@@ -72,7 +72,7 @@ def is_valid_key(key):
Valid characters for Vorbis comment field names are
ASCII 0x20 through 0x7D, 0x3D ('=') excluded.
"""
return INVALID_CHARS.search(key) is None
return key and INVALID_CHARS.search(key) is None
def flac_sort_pics_after_tags(metadata_blocks):

View File

@@ -67,6 +67,7 @@ VALID_KEYS = [
]
INVALID_KEYS = [
'',
'invalid=key',
'invalid\x19key',
'invalid~key',
@@ -91,7 +92,7 @@ class CommonVorbisTests:
supports_tag = self.format.supports_tag
for key in VALID_KEYS + list(TAGS.keys()):
self.assertTrue(supports_tag(key), '%r should be supported' % key)
for key in INVALID_KEYS + ['']:
for key in INVALID_KEYS:
self.assertFalse(supports_tag(key), '%r should be unsupported' % key)
@skipUnlessTestfile