diff --git a/mopidy/frontends/mpd/__init__.py b/mopidy/frontends/mpd/__init__.py index 57b41fc0..a2faedc2 100644 --- a/mopidy/frontends/mpd/__init__.py +++ b/mopidy/frontends/mpd/__init__.py @@ -96,5 +96,13 @@ class MpdSession(network.LineProtocol): def on_idle(self, subsystem): self.dispatcher.handle_idle(subsystem) + def decode(self, line): + try: + return super(MpdSession, self).decode(line.decode('string_escape')) + except ValueError: + logger.warning(u'Stopping actor due to unescaping error, data ' + 'supplied by client was not valid.') + self.stop() + def close(self): self.stop() diff --git a/tests/frontends/mpd/protocol/regression_test.py b/tests/frontends/mpd/protocol/regression_test.py index 8f2d6588..d4e4b2aa 100644 --- a/tests/frontends/mpd/protocol/regression_test.py +++ b/tests/frontends/mpd/protocol/regression_test.py @@ -121,3 +121,28 @@ class IssueGH69RegressionTest(protocol.BaseTestCase): self.sendRequest(u'clear') self.sendRequest(u'load "foo"') self.assertNotInResponse('song: None') + + +class IssueGH113RegressionTest(protocol.BaseTestCase): + """ + The issue: https://github.com/mopidy/mopidy/issues/113 + + How to reproduce: + + - Have a playlist with a name contining backslashes, like + "all lart spotify:track:\w\{22\} pastes". + - Try to load the playlist with the backslashes in the playlist name + escaped. + """ + + def test(self): + self.backend.stored_playlists.create( + u'all lart spotify:track:\w\{22\} pastes') + + self.sendRequest(u'lsinfo "/"') + self.assertInResponse( + u'playlist: all lart spotify:track:\w\{22\} pastes') + + self.sendRequest( + r'listplaylistinfo "all lart spotify:track:\\w\\{22\\} pastes"') + self.assertInResponse('OK')