Handle shlex parse errors in query strings

Provide context: offending query string.
Update changelog.
Fix #1290.
This commit is contained in:
Bruno Cauet 2015-01-31 19:47:19 +01:00
parent 557330e994
commit f284d8fad5
2 changed files with 5 additions and 1 deletions

View file

@ -1069,7 +1069,10 @@ def parse_query_string(s, model_cls):
# http://bugs.python.org/issue6988
if isinstance(s, unicode):
s = s.encode('utf8')
parts = [p.decode('utf8') for p in shlex.split(s)]
try:
parts = [p.decode('utf8') for p in shlex.split(s)]
except ValueError as exc:
raise ValueError("Cannot parse {0!r} (error was: {1})".format(s, exc))
return parse_query_parts(parts, model_cls)

View file

@ -86,6 +86,7 @@ Fixes:
like the bitrate. :bug:`1268`
* The error message when MusicBrainz is not reachable on the network is now
much clearer. Thanks to Tom Jaspers. :bug:`1190` :bug:`1272`
* Improve error messages when parsing query strings with shlex. :bug:`1290`
For developers: