Skip to content

Commit

Permalink
Do not do backslash substitution on regex queries
Browse files Browse the repository at this point in the history
As discussed in bug beetbox#3867, backslash replacement in query strings is a bit of a
hack but it is useful (see beetbox#3566 and beetbox#3567 for more discussion). However,
it breaks many regular expressions so this patch stops the replacement if the
query term contains '::', indicating it is a regex match.

This commit fixes beetbox#3867.

Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
  • Loading branch information
GrahamCobb committed Mar 8, 2021
1 parent c5556ff commit 553e38f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion beetsplug/web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ class QueryConverter(PathConverter):

def to_python(self, value):
queries = value.split('/')
return [query.replace('\\', os.sep) for query in queries]
"""Do not do path substitution on regex value tests"""
return [query if '::' in query else query.replace('\\', os.sep)
for query in queries]

def to_url(self, value):
return ','.join([v.replace(os.sep, '\\') for v in value])
Expand Down

0 comments on commit 553e38f

Please sign in to comment.