Skip to content

Commit

Permalink
beetsplug/web: fix translation of query path
Browse files Browse the repository at this point in the history
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+']`
  • Loading branch information
sumpfralle committed Dec 4, 2021
1 parent f315a13 commit 74d29b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion beetsplug/web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def to_python(self, value):
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):
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Bug fixes:
* :doc:`/plugins/lyrics`: Fix Genius search by using query params instead of body.
* :doc:`/plugins/unimported`: The new ``ignore_subdirectories`` configuration
option added in 1.6.0 now has a default value if it hasn't been set.
* :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:

Expand Down

0 comments on commit 74d29b5

Please sign in to comment.