Skip to content

beetsplug/web: fix translation of query path - #4182

Merged
sampsyo merged 1 commit into
beetbox:masterfrom
sumpfralle:patch-1
Jan 6, 2022
Merged

beetsplug/web: fix translation of query path#4182
sampsyo merged 1 commit into
beetbox:masterfrom
sumpfralle:patch-1

Conversation

@sumpfralle

Copy link
Copy Markdown
Contributor

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

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+']

I am not sure, why the issue was not noticed before. Maybe werkzeugs handling of routing maps has changed.

@sampsyo

sampsyo commented Dec 3, 2021

Copy link
Copy Markdown
Member

I think this looks right—I imagine it was just broken before! Thanks for tracking this down.

This seems related to #3567, so perhaps @nmeum would be able to take a look to make sure we're not doing anything wrong?

And in the mean time, @sumpfralle, any chance you could add a quick changelog entry describing the fix?

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+']`
@sumpfralle

Copy link
Copy Markdown
Contributor Author

I added a changelog entry.
Thank you for your time!

@sampsyo

sampsyo commented Jan 6, 2022

Copy link
Copy Markdown
Member

Looks good; thank you! Please feel free to weigh in if we are doing something wrong, @nmeum.

@sampsyo
sampsyo merged commit 493a503 into beetbox:master Jan 6, 2022
@snejus snejus added the web web plugin label Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

web web plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants