Skip to content
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

Merged
merged 1 commit into from
Nov 24, 2014

Conversation

mambocab
Copy link
Contributor

@mambocab mambocab commented Nov 9, 2014

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:

Wordfilter::add_words(['CLEAN']);

then Wordfilter::blacklisted?("this string was clean!") would return false, because it contains clean, not CLEAN. The JavaScript implementation doesn't seem to have this problem, I think because of the behavior of toLowerCase.

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!

The previous implementation didn't do any lowercasing on the word list, so added words containing capital letters were never filtered for.
@mambocab
Copy link
Contributor Author

@dariusk Just thought I'd ping you! Any changes I should make?

@dariusk
Copy link
Owner

dariusk commented Nov 24, 2014

Oh, I missed this! Yeah, seems great, thanks for the fix.

dariusk added a commit that referenced this pull request Nov 24, 2014
fixes ruby behavior on added strings with capitals
@dariusk dariusk merged commit a9bb411 into dariusk:master Nov 24, 2014
@dariusk
Copy link
Owner

dariusk commented Nov 24, 2014

Did you by any chance upload this to rubygems or similar? Just checking, in case it needs to be updated somewhere.

@mambocab
Copy link
Contributor Author

I haven't, but I'm not the original implementer. I didn't find a
wordfilter package on rubygems with a quick search, but I don't know
where else I would look.

On Mon, Nov 24, 2014 at 11:10 AM, Darius Kazemi notifications@github.com
wrote:

Did you by any chance upload this to rubygems or similar? Just checking,
in case it needs to be updated somewhere.


Reply to this email directly or view it on GitHub
#7 (comment).

@dariusk
Copy link
Owner

dariusk commented Nov 24, 2014

Cool, just checking. Thanks!

mambocab added a commit to mambocab/wordfilter that referenced this pull request Dec 21, 2014
fitnr pushed a commit to fitnr/wordfilter that referenced this pull request Dec 30, 2014
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
fitnr pushed a commit to fitnr/wordfilter that referenced this pull request Feb 10, 2015
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants