-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes ruby behavior on added strings with capitals #7
Conversation
The previous implementation didn't do any lowercasing on the word list, so added words containing capital letters were never filtered for.
@dariusk Just thought I'd ping you! Any changes I should make? |
Oh, I missed this! Yeah, seems great, thanks for the fix. |
fixes ruby behavior on added strings with capitals
Did you by any chance upload this to rubygems or similar? Just checking, in case it needs to be updated somewhere. |
I haven't, but I'm not the original implementer. I didn't find a On Mon, Nov 24, 2014 at 11:10 AM, Darius Kazemi notifications@github.com
|
Cool, just checking. Thanks! |
fixes the bug from dariusk#7
adds & tests lazy normalization to list-checking fixes the bug from dariusk#7 makes add_words accept arbitrary iterables makes add_words accept a string adds convenience function to module exposes module utilitites fixes basestring spelling fixes data reading fixes syntax error fixes blacklist extension
adds & tests lazy normalization to list-checking fixes the bug from dariusk#7 makes add_words accept arbitrary iterables makes add_words accept a string adds convenience function to module exposes module utilitites fixes basestring spelling fixes data reading fixes syntax error fixes blacklist extension
The previous implementation didn't do any downcasing on the word list, so added words containing capital letters were never filtered for, so if you added the string
CLEAN
:then
Wordfilter::blacklisted?("this string was clean!")
would return false, because it containsclean
, notCLEAN
. The JavaScript implementation doesn't seem to have this problem, I think because of the behavior oftoLowerCase
.This implementation downcases the contents of the blacklist lazily, just before it's consulted. In principle, I'm pretty sure that's the right way to do it, but I have no idea if this implementation is good Ruby -- it may belong in
init_first_time
or equivalent. Seems to work, though!