Questo è uno strumento di moderazione utile, ma ha scarso supporto per i caratteri non inglesi, e la presenza di caratteri non inglesi può persino influire sul rilevamento di inglese e numeri. Qui, prendendo come esempio la parola cinese semplificata “测试” (Test), l’elenco delle parole monitorate contiene tre elementi: “测试”, “Test” e “123”. Nel test seguente, nessuno dei tre esempi ha attivato le parole monitorate.
Ho cercato sul sito e ho trovato un altro problema simile relativo alle parole censurate: Censored words do not respect word boundaries in non-latin alphabet . Sembra che questo sia un problema comune in tutto il sistema di corrispondenza delle parole monitorate?
2 Mi Piace
Grazie per la segnalazione, questo verrà risolto da
main ← fix/watched-words-cjk-boundaries
opened 02:44PM - 16 Feb 26 UTC
Watched words failed to match in CJK (Chinese, Japanese, Korean) and other space… less scripts because word boundary detection relied on whitespace or non-word characters. Languages like Chinese don't use spaces between words, so "测试" inside "这是一个测试文本" was never matched.
Introduce a SPACELESS_SCRIPTS constant covering Han, Hiragana, Katakana, Hangul, Thai, Lao, Myanmar, Khmer, and Tibetan Unicode ranges. Update `match_word_regexp` for both Ruby and JS engines so that characters from these scripts are treated as word boundaries. This allows a CJK watched word to match when surrounded by other CJK characters, and a Latin watched word to match when adjacent to CJK text (e.g., "Test" in "我的Test很好"), while still preventing partial Latin matches (e.g., "Testing" does not match "Test").
Also fix the admin watched word testing modal to use `RegExp.exec()` with capture group extraction instead of `String.match()`, since the new boundary patterns include a leading consuming group.
Remove the outdated "non-chrome browsers do not support lookbehind" comment — all major browsers have supported lookbehind since 2023.
https://meta.discourse.org/t/71288
https://meta.discourse.org/t/396109
2 Mi Piace