From 7a37e25152e390cc41d4f7ab6064fdec12a5a0a2 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Thu, 28 Oct 2021 21:29:40 +0200 Subject: [PATCH] vorbis: empty string is not a valid Vorbis comment key --- picard/formats/vorbis.py | 2 +- test/formats/test_vorbis.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/picard/formats/vorbis.py b/picard/formats/vorbis.py index da3274ba5..ecbedade5 100644 --- a/picard/formats/vorbis.py +++ b/picard/formats/vorbis.py @@ -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): diff --git a/test/formats/test_vorbis.py b/test/formats/test_vorbis.py index 214b9f5b8..400302443 100644 --- a/test/formats/test_vorbis.py +++ b/test/formats/test_vorbis.py @@ -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