local: Fix crash on non-ASCII chars in URIs
This commit is contained in:
parent
e448d77eb7
commit
b0ae7d3c6f
@ -106,6 +106,9 @@ of the following extensions as well:
|
|||||||
e.g. HTTP radio streams and not just ``local:track:...`` URIs. This used to
|
e.g. HTTP radio streams and not just ``local:track:...`` URIs. This used to
|
||||||
work, but was broken in Mopidy 0.15.0. (Fixes: :issue:`527`)
|
work, but was broken in Mopidy 0.15.0. (Fixes: :issue:`527`)
|
||||||
|
|
||||||
|
- Fixed crash when playing ``local:track:...`` URIs which contained non-ASCII
|
||||||
|
chars after uridecode.
|
||||||
|
|
||||||
**MPD frontend**
|
**MPD frontend**
|
||||||
|
|
||||||
- Made the formerly unused commands ``outputs``, ``enableoutput``, and
|
- Made the formerly unused commands ``outputs``, ``enableoutput``, and
|
||||||
|
|||||||
@ -13,7 +13,7 @@ class LocalPlaybackProvider(base.BasePlaybackProvider):
|
|||||||
def change_track(self, track):
|
def change_track(self, track):
|
||||||
media_dir = self.backend.config['local']['media_dir']
|
media_dir = self.backend.config['local']['media_dir']
|
||||||
# TODO: check that type is correct.
|
# TODO: check that type is correct.
|
||||||
file_path = path.uri_to_path(track.uri).split(':', 1)[1]
|
file_path = path.uri_to_path(track.uri).split(b':', 1)[1]
|
||||||
file_path = os.path.join(media_dir, file_path)
|
file_path = os.path.join(media_dir, file_path)
|
||||||
track = track.copy(uri=path.path_to_uri(file_path))
|
track = track.copy(uri=path.path_to_uri(file_path))
|
||||||
return super(LocalPlaybackProvider, self).change_track(track)
|
return super(LocalPlaybackProvider, self).change_track(track)
|
||||||
|
|||||||
@ -72,6 +72,14 @@ class LocalPlaybackProviderTest(unittest.TestCase):
|
|||||||
self.playback.play()
|
self.playback.play()
|
||||||
self.assertEqual(self.playback.state, PlaybackState.PLAYING)
|
self.assertEqual(self.playback.state, PlaybackState.PLAYING)
|
||||||
|
|
||||||
|
def test_play_uri_with_non_ascii_bytes(self):
|
||||||
|
# Regression test: If trying to do .split(u':') on a bytestring, the
|
||||||
|
# string will be decoded from ASCII to Unicode, which will crash on
|
||||||
|
# non-ASCII strings, like the bytestring the following URI decodes to.
|
||||||
|
self.add_track('local:track:12%20Doin%E2%80%99%20It%20Right.flac')
|
||||||
|
self.playback.play()
|
||||||
|
self.assertEqual(self.playback.state, PlaybackState.PLAYING)
|
||||||
|
|
||||||
def test_initial_state_is_stopped(self):
|
def test_initial_state_is_stopped(self):
|
||||||
self.assertEqual(self.playback.state, PlaybackState.STOPPED)
|
self.assertEqual(self.playback.state, PlaybackState.STOPPED)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user