mirror of
https://github.com/fergalmoran/picard.git
synced 2026-01-28 19:33:59 +00:00
PICARD-1492: Added tests and docs for vorbis.sanitize_key
This commit is contained in:
@@ -53,6 +53,10 @@ INVALID_CHARS = re.compile('([^\x20-}]|=)')
|
||||
|
||||
|
||||
def sanitize_key(key):
|
||||
"""
|
||||
Remove characters from key which are invalid for a Vorbis comment field name.
|
||||
See https://www.xiph.org/vorbis/doc/v-comment.html#vectorformat
|
||||
"""
|
||||
return INVALID_CHARS.sub('', key)
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ from picard.coverart.image import (
|
||||
TagCoverArtImage,
|
||||
)
|
||||
import picard.formats
|
||||
from picard.formats import ext_to_format
|
||||
from picard.formats import ext_to_format, vorbis
|
||||
from picard.metadata import Metadata
|
||||
|
||||
settings = {
|
||||
@@ -609,6 +609,12 @@ class OptimFROGDUalStreamTest(CommonTests.FormatsTest):
|
||||
self.assertEqual(metadata['~format'], 'OptimFROG DualStream Audio')
|
||||
|
||||
|
||||
class VorbisUtilTest(PicardTestCase):
|
||||
def test_sanitize_key(self):
|
||||
sanitized = vorbis.sanitize_key(' \x1f=}~')
|
||||
self.assertEqual(sanitized, ' }')
|
||||
|
||||
|
||||
cover_settings = {
|
||||
'embed_only_one_front_image': True,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user