beetsplug/web: fix translation of query path

The routing map translator `QueryConverter` was misconfigured:
* decoding (parsing a path): splitting with "/" as tokenizer
* encoding (translating back to a path): joining items with "," as separator

This caused queries containing more than one condition (separated by a
slash) to return an empty result.  Queries with only a single condition
were not affected.

Instead the encoding should have used the same delimiter (the slash) for the
backward conversion.

How to reproduce:
* query: `/album/query/albumartist::%5Efoo%24/original_year%2B/year%2B/album%2B`
* resulting content in parsed argument `queries` in the `album_query` function:
    * previous (wrong): `['albumartist::^foo$,original_year+,year+,album+']`
    * new (correct): `['albumartist::^foo$', 'original_year+', 'year+', 'album+']`
This commit is contained in:
Lars Kruse 2021-12-03 18:20:45 +01:00
parent 5d0442f094
commit a09c80447a
2 changed files with 4 additions and 1 deletions

View file

@ -261,7 +261,7 @@ class QueryConverter(PathConverter):
for query in queries]
def to_url(self, value):
return ','.join([v.replace(os.sep, '\\') for v in value])
return '/'.join([v.replace(os.sep, '\\') for v in value])
class EverythingConverter(PathConverter):

View file

@ -28,6 +28,9 @@ Bug fixes:
``r128_album_gain`` fields was changed from integer to float to fix loss of
precision due to truncation.
:bug:`4169`
* :doc:`plugins/web`: Fix handling of "query" requests. Previously queries
consisting of more than one token (separated by a slash) always returned an
empty result.
For packagers: