mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 06:10:10 +08:00
FIX: censored words should support * as wildcard
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
function escapeRegexp(text) {
|
||||
return text.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||
return text.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&').replace(/\*/g, "\S*");
|
||||
}
|
||||
|
||||
export function censorFn(censoredWords, censoredPattern, replacementLetter) {
|
||||
|
@ -14,7 +14,7 @@ const rawOpts = {
|
||||
default_code_lang: 'auto',
|
||||
censored_pattern: '\\d{3}-\\d{4}|tech\\w*'
|
||||
},
|
||||
censoredWords: 'shucks|whiz|whizzer|a**le',
|
||||
censoredWords: 'shucks|whiz|whizzer|a**le|badword*',
|
||||
getURL: url => url
|
||||
};
|
||||
|
||||
@ -604,6 +604,9 @@ QUnit.test("censoring", assert => {
|
||||
assert.cooked("I have a pen, I have an a**le",
|
||||
"<p>I have a pen, I have an ■■■■■</p>",
|
||||
"it escapes regexp chars");
|
||||
assert.cooked("No badword or apple here plz.",
|
||||
"<p>No ■■■■■■■ or ■■■■■ here plz.</p>",
|
||||
"it handles * as wildcard");
|
||||
});
|
||||
|
||||
QUnit.test("code blocks/spans hoisting", assert => {
|
||||
|
Reference in New Issue
Block a user