ChaseFlorell / jQuery.ProfanityFilter

filter out profane words on the client
https://chaseflorell.github.io/jQuery.ProfanityFilter/demo/
MIT License
110 stars 42 forks source link

ASCII Character code not working #7

Open delacruzjames opened 10 years ago

delacruzjames commented 10 years ago

[ ["@$$f@ce"], ["@$$h0le"], ["@$$he@d"], ["@$$hole"], ["@$$hols"], ]

MonrealRyan commented 9 years ago

+1

2gen commented 9 years ago

Got a fix for this.

Add the following function:

function escapeRegExp(str) {
    return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}

Find the regex that is doing the string replace, I used the non-minified version and replace it with the following (around line 161):

re = new RegExp('\\b' + escapeRegExp(badWords[i]) + '\\b', 'gi');

ChaseFlorell commented 8 years ago

@2gen would you drop a PR on this? I'd be happy to accept.