FIX: Replace censored watched word consistently (#12486)

Applying oneboxes and replacing censored watched words does not happen
in a strict order which often lead to inconsistencies. This commit
fixes the behavior and will never censor oneboxes.

To make it always censor oneboxes implies significant changes to the
PrettyText pipeline.
This commit is contained in:
Bianca Nenciu
2021-03-23 13:09:24 +02:00
committed by GitHub
parent deb9e3cd22
commit d7bd62d9cf
2 changed files with 5 additions and 0 deletions

View File

@@ -3,6 +3,10 @@ import { censorFn } from "pretty-text/censored-words";
function recurse(tokens, apply) {
let i;
for (i = 0; i < tokens.length; i++) {
if (tokens[i].type === "html_raw" && tokens[i].onebox) {
continue;
}
apply(tokens[i]);
if (tokens[i].children) {
recurse(tokens[i].children, apply);

View File

@@ -81,6 +81,7 @@ function applyOnebox(state, silent) {
child.type = "html_raw";
child.content = cached;
child.inline = true;
child.onebox = true;
text.type = "html_raw";
text.content = "";