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

No Substring Filter? #100

Open
RADesai opened this issue Dec 24, 2020 · 12 comments
Open

No Substring Filter? #100

RADesai opened this issue Dec 24, 2020 · 12 comments

Comments

@RADesai
Copy link

RADesai commented Dec 24, 2020

Hopefully I'm missing something or using the package incorrectly but seems like its not finding bad words as substrings..?

import Filter from 'bad-words';

const filter = new Filter();

console.log(filter.clean('xyz ass4ca')); // xyz ass4ca
console.log(filter.clean('xyz 555ass')); // xyz 555ass
console.log(filter.clean('xyz ass'));    // xyz ***
@daniandl
Copy link

Did you find a solution or another library that does this?

@brianreavis
Copy link

Bass. Assistant. Raccoon. Shitake mushrooms. Peacock.
B***. ***istant. Rac****. ****ake mushrooms. Pea****.

Is this really a good idea?

@daniandl
Copy link

It would be nice to at least have the option, as certain racial slurs do not really fit into any other words like Shitake :)

@dolanmiu
Copy link

dolanmiu commented Mar 9, 2021

people bypass the filter by doing adding an underscore on the word, or adding an extra r on the n word

ass_

@djflorio
Copy link

+1 for adding the option to filter substrings. I'm creating a referral code generator that spits out a random alphanumeric code that the user can send to a friend to get them to sign up. We want to reduce the chances of offensive words sneaking into the randomly-generated string.

@dodocodes
Copy link

I'd love it if there was a way to force certain bad words from being filtered out, like the F word... how many times does the F word show up inside of other words?

Warning, the following contains language that may be found as offensive!

image

All of the above totally bypassed the isProfane function.

@BradKML
Copy link

BradKML commented Mar 22, 2021

@dodocodes is correct in this regard, however, @brianreavis brings up https://www.wikiwand.com/en/Scunthorpe_problem
There should be a way to enhance accuracy, e.g. detecting compound curses and ignoring special character padding.

@RADesai
Copy link
Author

RADesai commented Apr 15, 2021

Bass. Assistant. Raccoon. Shitake mushrooms. Peacock.
B***. ***istant. Rac****. ****ake mushrooms. Pea****.

Is this really a good idea?

Fair point but for some use cases it can be desired, for example when we are generating random character serial numbers for item labels, we would like to filter any expletives that can be accidentally generated as as substring

@raymolla7
Copy link

Has anyone found a way to enable a substring filter? As mentioned above it is very useful in some use cases.

@ktmeagher
Copy link

Bass. Assistant. Raccoon. Shitake mushrooms. Peacock.
B***. ***istant. Rac****. ****ake mushrooms. Pea****.

Is this really a good idea?

Fair point but for some use cases it can be desired, for example when we are generating random character serial numbers for item labels, we would like to filter any expletives that can be accidentally generated as as substring

I agree that having the option to apply the filter for words containing bad words is desirable. The exclude list should be used to allow words like "raccoon" and "peacock" to pass without issue. Since developers can manage that list using the "removeWords" feature, it should be fairly straight-forward to implement this option without breaking changes.

@pankaj9296
Copy link

pankaj9296 commented Mar 3, 2023

people bypass the filter by doing adding an underscore on the word, or adding an extra r on the n word

ass_

use the following splitRegex to consider _ as a word boundary:
new Filter({splitRegex: /(?:(?=[a-zA-Z0-9]))(?<![a-zA-Z0-9])|(?<=[a-zA-Z0-9])(?![a-zA-Z0-9])/})

@BradKML
Copy link

BradKML commented Mar 10, 2023

A slight thought: compound word bounds are good grounds for filtering, inherent words with coincidental substring is not.
Problem: how do toy know it is not a prefix or suffix?
the "B" in Bass is not a word. The "istant" in Assistant is not a word. The "Rac" in Raccoon is not a word. The "ake" in Shitake is not a word... BUT "Pea" is a word in Peacock. This is can be captured in secondary sense through wordlists.

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

No branches or pull requests

10 participants