diff --git a/app/assets/javascripts/discourse/dialects/censored_dialect.js b/app/assets/javascripts/discourse/dialects/censored_dialect.js index 079b84ec9c4..1cb38a9115a 100644 --- a/app/assets/javascripts/discourse/dialects/censored_dialect.js +++ b/app/assets/javascripts/discourse/dialects/censored_dialect.js @@ -6,7 +6,7 @@ Discourse.Dialect.addPreProcessor(function(text) { if (!censorRegexp) { var split = censored.split("|"); if (split && split.length) { - censorRegexp = new RegExp("\\b" + split.map(function (t) { return "(" + t.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&') + ")"; }).join("|") + "\\b", "ig"); + censorRegexp = new RegExp("\\b(?:" + split.map(function (t) { return "(" + t.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&') + ")"; }).join("|") + ")\\b", "ig"); } } diff --git a/test/javascripts/lib/markdown-test.js.es6 b/test/javascripts/lib/markdown-test.js.es6 index 08eb2f87d49..2fa4f7066c5 100644 --- a/test/javascripts/lib/markdown-test.js.es6 +++ b/test/javascripts/lib/markdown-test.js.es6 @@ -481,11 +481,14 @@ test("images", function() { }); test("censoring", function() { - Discourse.SiteSettings.censored_words = "shucks|whiz"; + Discourse.SiteSettings.censored_words = "shucks|whiz|whizzer"; cooked("aw shucks, golly gee whiz.", "
aw ■■■■■■, golly gee ■■■■.
", "it censors words in the Site Settings"); cooked("you are a whizzard! I love cheesewhiz. Whiz.", "you are a whizzard! I love cheesewhiz. ■■■■.
", "it doesn't censor words unless they have boundaries."); + cooked("you are a whizzer! I love cheesewhiz. Whiz.", + "you are a ■■■■■■■! I love cheesewhiz. ■■■■.
", + "it censor words even if previous partical matches exist."); });