Skip to content

Commit

Permalink
[gmdfalk#36] Replace prefix search with substring search
Browse files Browse the repository at this point in the history
In a few rare situations the best blocklist filter string is not a
prefix of the song. A substring search will handle these anomalies
correctly, with the caveat that it is inevitably much less conservative.

At least four instances of a pattern similar to the following have been
observed:

    FRESH LIGE NU Filtr
    KLIK & LYT Filtr

Here, "Filtr" is the desired filter string but isn't a prefix. The real
issue here is that the prefix filter is trivially bypassed in theory.
While I have only one example of this, the pattern is straight-forward.

An alternative could be to optionally try either a substring search or a
suffix search after a failed prefix search, letting users opt in to the
more dangerous behaviour. Personally I have had no issues with
substrings but my music consumption simply isn't big enough for my
experience to have much weight.

Note that I don't remember if "Filtr" is actually a suffix in the
examples above. That is, I have forgotten if anything comes after it.
  • Loading branch information
Mikkel Kjeldsen committed Feb 24, 2015
1 parent ddb6fd6 commit 9504844
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion blockify/blocklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def find(self, song):
# Arbitrary minimum length of 4 to avoid ambiguous song names.
while len(song) > 4:
for item in self:
if item.startswith(song):
if song in item:
return item
song = song[:len(song) / 2]

Expand Down

0 comments on commit 9504844

Please sign in to comment.