Merge pull request #2881 from DeanMarkTaylor/patch-1
FIX: Censored word match fail if earlier partial match
This commit is contained in:
commit
8b508e704b
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.",
|
||||
"<p>aw ■■■■■■, golly gee ■■■■.</p>",
|
||||
"it censors words in the Site Settings");
|
||||
cooked("you are a whizzard! I love cheesewhiz. Whiz.",
|
||||
"<p>you are a whizzard! I love cheesewhiz. ■■■■.</p>",
|
||||
"it doesn't censor words unless they have boundaries.");
|
||||
cooked("you are a whizzer! I love cheesewhiz. Whiz.",
|
||||
"<p>you are a ■■■■■■■! I love cheesewhiz. ■■■■.</p>",
|
||||
"it censor words even if previous partical matches exist.");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue