bpd: fix crash w/ unicode extensions (GC-439)

This commit is contained in:
Adrian Sampson 2012-09-17 10:24:34 -07:00
parent 49a6b993d3
commit ef248576f0
3 changed files with 11 additions and 0 deletions

View file

@ -1135,6 +1135,9 @@ class Library(BaseLibrary):
# Preserve extension.
_, extension = pathmod.splitext(item.path)
if fragment:
# Outputting Unicode.
extension = extension.decode('utf8', 'ignore')
subpath += extension.lower()
if fragment:

View file

@ -27,6 +27,8 @@ Changelog
disagree.
* Fix a bug that caused the :doc:`/plugins/lastgenre` and other plugins not to
modify files' tags even when they successfully change the database.
* Fix a VFS bug leading to a crash in the :doc:`/plugins/bpd` when files had
non-ASCII extensions.
.. _Tomahawk resolver: http://beets.radbox.org/blog/tomahawk-resolver.html

View file

@ -442,6 +442,12 @@ class DestinationTest(unittest.TestCase):
finally:
sys.getfilesystemencoding = oldfunc
def test_unicode_extension_in_fragment(self):
self.lib.path_formats = [('default', u'foo')]
self.i.path = util.bytestring_path(u'bar.caf\xe9')
dest = self.lib.destination(self.i, platform='linux2', fragment=True)
self.assertEqual(dest, u'foo.caf\xe9')
class PathFormattingMixin(object):
"""Utilities for testing path formatting."""
def _setf(self, fmt):