Unescapes all incoming MPD requests (fixes #113)

This commit is contained in:
Stein Magnus Jodal 2011-08-02 02:49:34 +02:00
parent 2d4ed8572a
commit d8959341e8
2 changed files with 33 additions and 0 deletions

View File

@ -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()

View File

@ -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')