From 78ffaeb8d29f92d9c107780bfe43017a85fff7a9 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 22 Aug 2015 23:51:07 +0200 Subject: [PATCH] playlists: Fix crash on urilist comment with non-ASCII chars Fixes #1265 --- docs/changelog.rst | 4 ++++ mopidy/internal/playlists.py | 2 +- tests/internal/test_playlists.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 55357087..a310e7e8 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -16,6 +16,10 @@ Bug fix release. to remove "file" from the :confval:`stream/protocols` config, and then proceed startup. (Fixes: :issue:`1248`, PR: :issue:`1254`) +- Stream: Fix bug in new playlist parser. A non-ASCII char in an urilist + comment would cause a crash while parsing due to comparision of a non-ASCII + bytestring with a Unicode string. (Fixes: :issue:`1265`) + - File: Adjust log levels when failing to expand ``$XDG_MUSIC_DIR`` into a real path. This usually happens when running Mopidy as a system service, and thus with a limited set of environment variables. (Fixes: :issue:`1249`, PR: diff --git a/mopidy/internal/playlists.py b/mopidy/internal/playlists.py index 219d3ec6..f8e654af 100644 --- a/mopidy/internal/playlists.py +++ b/mopidy/internal/playlists.py @@ -122,7 +122,7 @@ def parse_asx(data): def parse_urilist(data): result = [] for line in data.splitlines(): - if not line.strip() or line.startswith('#'): + if not line.strip() or line.startswith(b'#'): continue try: validation.check_uri(line) diff --git a/tests/internal/test_playlists.py b/tests/internal/test_playlists.py index 21537813..9a1c49d5 100644 --- a/tests/internal/test_playlists.py +++ b/tests/internal/test_playlists.py @@ -23,7 +23,7 @@ file:///tmp/baz URILIST = b""" file:///tmp/foo -# a comment +# a comment \xc5\xa7\xc5\x95 file:///tmp/bar file:///tmp/baz