Ceci devrait corriger le problème pour de bon cette fois. Nous avions eu une certaine incohérence entre la version Ruby et la version JS des expressions régulières utilisées, mais cela n’est plus nécessaire.
main ← fix/unify-word-boundary-regex
opened 11:54PM - 20 Feb 26 UTC
The CJK fix (d7a53ada16) introduced separate boundary patterns for Ruby and JS e… ngines in `match_word_regexp`. The Ruby engine used `[:word:]` (which includes digits), while the JS engine used `\P{L}` (non-Letter). Since digits are not letters, the JS pattern treated them as valid word boundaries — causing "123Test" to match as "3Test" and standalone number watched words like "123" to match inside "abc123".
Replace both engine-specific patterns with a single unified pattern using Unicode property classes (`\p{L}`, `\p{M}`, `\p{N}`, `\p{Pc}`) that work identically in Ruby and JavaScript. This treats letters, marks, numbers, and connector punctuation as word characters in boundary checks, which fixes the number-matching bug for JS consumers while preserving the existing correct behavior on the Ruby side.
Since `match_word_regexp` no longer branches on engine, remove the now-dead `engine:` parameter from all 5 method signatures that threaded it through (`match_word_regexp`, `word_to_regexp`, `regexps_for_action`, `compiled_regexps_for_action`, `serialized_regexps_for_action`) and all call sites passing `engine: :js` (serializers, pretty_text).
https://meta.discourse.org/t/396110
https://meta.discourse.org/t/396109
Follow-up to d7a53ada16 (#37844)
3 « J'aime »