-
Notifications
You must be signed in to change notification settings - Fork 326
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
Issue with symbols / emoji only strings #93
Comments
Getting the same problem. Will try the workaround by @lkgoerges |
Fitmavincent
referenced
this issue
Nov 24, 2020
Issue: Using /\b/ to split the text is limited to languages using only the 63 characters: ``` a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 _ ``` cf https://stackoverflow.com/a/2449892 For example, in French, the string `je suis français` will be split into `["je", " ", "suis", " ", "fran", "ç", "ais"]` which won't allow to perform the bad-words cleaning. Therefore I added an option `splitRegex` which allow to overwrite the regex used to split.
brianreavis
added a commit
to naturalatlas/badwords
that referenced
this issue
Dec 4, 2020
"TypeError: Cannot read property '0' of null"
brianreavis
added a commit
to naturalatlas/badwords
that referenced
this issue
Dec 4, 2020
"TypeError: Cannot read property '0' of null"
johnnyapol
added a commit
to TornDotSpace/Torn
that referenced
this issue
Dec 29, 2020
This isn't so much of a fix as it is a workaround. web-mech/badwords#93 tracks the issue. This change also includes a minor fix to kick clients for exceptions in debug mode.
For those interested, I'm using this as a workaround for now. // filename bad-words-hacked.js
const Filter = require('bad-words')
class FilterHacked extends Filter {
cleanHacked(string) {
try {
return this.clean(string);
} catch {
const joinMatch = this.splitRegex.exec(string);
const joinString = (joinMatch && joinMatch[0]) || '';
return string.split(this.splitRegex).map((word) => {
return this.isProfane(word) ? this.replaceWord(word) : word;
}).join(joinString);
}
}
}
module.exports = FilterHacked Example code: var Filter = require('./bad-words-hacked');
filter = new Filter();
const filteredString = filter.cleanHacked(string); |
callumooi
pushed a commit
to OtherOceanInteractive/badwords
that referenced
this issue
Apr 19, 2021
"TypeError: Cannot read property '0' of null"
Looks like this repo is pretty much abandoned. Does anyone have a fork they plan on maintaining? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When running the
clean()
function with a string containing only emojis or symbols I receive the following error:As a workaround, I currently add "ABC" at the end of every string and remove it after the cleanup.
Example code:
The text was updated successfully, but these errors were encountered: