A platform for community discussion. Free, open, simple.
FIX: censored words should support * as wildcard
Neil Lalondead62f1099cdb
diff --git a/app/assets/javascripts/pretty-text/censored-words.js.es6 b/app/assets/javascripts/pretty-text/censored-words.js.es6index 58900460bcb..ffb0cce3aeb 100644--- a/app/assets/javascripts/pretty-text/censored-words.js.es6+++ b/app/assets/javascripts/pretty-text/censored-words.js.es6@@ -1,5 +1,5 @@function escapeRegexp(text) {- return text.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');+ return text.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&').replace(/\*/g, "\S*");}export function censorFn(censoredWords, censoredPattern, replacementLetter) {diff --git a/test/javascripts/lib/pretty-text-test.js.es6 b/test/javascripts/lib/pretty-text-test.js.es6index 65803e8b188..89704ee4cbd 100644--- a/test/javascripts/lib/pretty-text-test.js.es6+++ b/test/javascripts/lib/pretty-text-test.js.es6@@ -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 => {