From 74d29b538cd30d0824612afeba7c209be9a8c246 Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Fri, 3 Dec 2021 18:20:45 +0100 Subject: [PATCH] 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+']` --- beetsplug/web/__init__.py | 2 +- docs/changelog.rst | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index 240126e957..63f7f92ad1 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -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): diff --git a/docs/changelog.rst b/docs/changelog.rst index 8d95b7fb03..2d0ec2a093 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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: