m3u: Fix crash if playlist filename is not decodable
...with the current file system encoding Fixes #1209
This commit is contained in:
parent
3970e69686
commit
fb859a9f23
@ -12,6 +12,10 @@ Bug fix release.
|
||||
- Fix reversal of ``Title`` and ``Name`` in MPD protocol (Fixes: :issue:`1212`
|
||||
PR: :issue:`1214`)
|
||||
|
||||
- Fix crash if an M3U file in the :confval:`m3u/playlist_dir` directory has a
|
||||
file name not decodable with the current file system encoding. (Fixes:
|
||||
:issue:`1209`)
|
||||
|
||||
|
||||
v1.0.7 (2015-06-26)
|
||||
===================
|
||||
|
||||
@ -66,7 +66,7 @@ class M3UPlaylistsProvider(backend.PlaylistsProvider):
|
||||
for path in glob.glob(os.path.join(self._playlists_dir, b'*.m3u')):
|
||||
relpath = os.path.basename(path)
|
||||
uri = translator.path_to_playlist_uri(relpath)
|
||||
name = os.path.splitext(relpath)[0].decode(encoding)
|
||||
name = os.path.splitext(relpath)[0].decode(encoding, 'replace')
|
||||
tracks = translator.parse_m3u(path)
|
||||
playlists[uri] = Playlist(uri=uri, name=name, tracks=tracks)
|
||||
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
# encoding: utf-8
|
||||
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
import urllib
|
||||
|
||||
import pykka
|
||||
|
||||
@ -108,6 +111,7 @@ class M3UPlaylistsProviderTest(unittest.TestCase):
|
||||
|
||||
with open(path) as f:
|
||||
m3u = f.read().splitlines()
|
||||
|
||||
self.assertEqual(['#EXTM3U', '#EXTINF:60,Test', track.uri], m3u)
|
||||
|
||||
def test_latin1_playlist_contents_is_written_to_disk(self):
|
||||
@ -142,9 +146,17 @@ class M3UPlaylistsProviderTest(unittest.TestCase):
|
||||
self.assertEqual(playlist.name, result.name)
|
||||
self.assertEqual(track.uri, result.tracks[0].uri)
|
||||
|
||||
@unittest.SkipTest
|
||||
def test_santitising_of_playlist_filenames(self):
|
||||
pass
|
||||
def test_load_playlist_with_nonfilesystem_encoding_of_filename(self):
|
||||
uri = 'm3u:%s.m3u' % urllib.quote('øæå'.encode('latin-1'))
|
||||
path = playlist_uri_to_path(uri, self.playlists_dir)
|
||||
with open(path, 'wb+') as f:
|
||||
f.write(b'#EXTM3U\n')
|
||||
|
||||
self.core.playlists.refresh()
|
||||
|
||||
self.assertEqual(len(self.core.playlists.as_list()), 1)
|
||||
result = self.core.playlists.lookup(uri)
|
||||
self.assertEqual('\ufffd\ufffd\ufffd', result.name)
|
||||
|
||||
@unittest.SkipTest
|
||||
def test_playlists_dir_is_created(self):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user