Skip to content

Commit

Permalink
bpd: fix crash w/ unicode extensions (GC-439)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampsyo authored and Matteo Mecucci committed Dec 12, 2012
1 parent 1218236 commit ae7366c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,9 @@ def destination(self, item, pathmod=None, fragment=False,

# Preserve extension.
_, extension = pathmod.splitext(item.path)
if fragment:
# Outputting Unicode.
extension = extension.decode('utf8', 'ignore')
subpath += extension.lower()

if fragment:
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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.

1.0b15 (July 26, 2012)
----------------------
Expand Down
6 changes: 6 additions & 0 deletions test/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,12 @@ def test_non_mbcs_characters_on_windows(self):
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):
Expand Down

0 comments on commit ae7366c

Please sign in to comment.