mirror of
https://github.com/beetbox/beets.git
synced 2026-02-22 23:33:50 +01:00
_sanitize_path now uses a non-unicode regex
This commit is contained in:
parent
d1c6448da8
commit
181949d1a3
2 changed files with 13 additions and 3 deletions
|
|
@ -178,10 +178,10 @@ def _bytestring_path(path):
|
|||
# Note: POSIX actually supports \ and : -- I just think they're
|
||||
# a pain. And ? has caused problems for some.
|
||||
CHAR_REPLACE = [
|
||||
(re.compile(r'[\\/\?]|^\.'), u'_'),
|
||||
(re.compile(r':'), u'-'),
|
||||
(re.compile(r'[\\/\?]|^\.'), '_'),
|
||||
(re.compile(r':'), '-'),
|
||||
]
|
||||
CHAR_REPLACE_WINDOWS = re.compile('["\*<>\|]|^\.|\.$'), u'_u'
|
||||
CHAR_REPLACE_WINDOWS = re.compile('["\*<>\|]|^\.|\.$'), '_'
|
||||
def _sanitize_path(path, plat=None):
|
||||
"""Takes a path and makes sure that it is legal for the specified
|
||||
platform (as returned by platform.system()). Returns a new path.
|
||||
|
|
|
|||
|
|
@ -465,6 +465,16 @@ class PathStringTest(unittest.TestCase):
|
|||
alb = self.lib.get_album(self.i)
|
||||
self.assertEqual(path, alb.artpath)
|
||||
|
||||
def test_sanitize_path_with_special_chars(self):
|
||||
path = 'b\xe1r?'
|
||||
new_path = beets.library._sanitize_path(path)
|
||||
self.assert_(new_path.startswith('b\xe1r'))
|
||||
|
||||
def test_sanitize_path_returns_bytestring(self):
|
||||
path = 'b\xe1r?'
|
||||
new_path = beets.library._sanitize_path(path)
|
||||
self.assert_(isinstance(new_path, str))
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
|
|
|||
Loading…
Reference in a new issue