xavier / expletive

Profanity filter library for Elixir
Apache License 2.0
43 stars 9 forks source link

it doesn't work when the word has `?` #6

Open Tomoka64 opened 3 years ago

Tomoka64 commented 3 years ago

Hi! I have been using your library. it is very awesome! one thing i noticed is when trying to filter with question mark, it doesnt work like other words.

iex(4)> c = Expletive.configure(blacklist: ["cc?", "cc?cc", "ó?ó"])
%Expletive.Configuration{
  blacklist: ["cc?", "cc?cc", "ó?ó"],
  regex: ~r/\b(?:cc\?|cc\?cc|ó\?ó)\b/iu,
  replacement: :default,
  whitelist: [] 
}
iex(5)> Expletive.sanitize "cc?", c, {:repeat, "*"}               
"cc?"
iex(6)> Expletive.sanitize "cc?cc", c, {:repeat, "*"}
"***cc"
xavier commented 3 years ago

Thanks for your report.

I had a quick look and this might be somewhat tricky to fix as the "?" character trips the word boundary scanning which relies on \b anchors.

I could not get a quick fix to work without any regression in the short amount of time I had to devote to this today, I'll have to come up with an appropriate solution.

Ideas are of course welcome! 😃