fix: strip reply/forward prefixes followed by a full-width colon

The prefix-stripping regex only matched an ASCII ":", so a localized
prefix from a CJK mail client (e.g. "回复:foo", using the full-width
colon U+FF1A) was left in place. On reply this caused the user's own
prefix to be stacked on top, growing the subject chain.

Accept both ":" and ":" after the prefix token. Adds tests.
This commit is contained in:
Stefan Hildebrandt
2026-06-24 15:56:38 +02:00
committed by Linus Rath
parent 751f3c1685
commit 8af6694152
2 changed files with 14 additions and 23 deletions
+3 -1
View File
@@ -64,8 +64,10 @@ function buildPrefixRegex(tokens: string[]): RegExp {
// Sort by length DESC so longer tokens (e.g. "Пересл") win over their
// shorter prefixes (e.g. "Пер") during alternation matching.
escaped.sort((a, b) => b.length - a.length);
// Accept both the ASCII colon and the full-width colon "" (U+FF1A) that CJK
// mail clients emit after a localized prefix (e.g. "回复:foo").
return new RegExp(
`^\\s*(?:${escaped.join("|")})(?:\\[\\d+\\]|\\*\\d*)?\\s*:\\s*`,
`^\\s*(?:${escaped.join("|")})(?:\\[\\d+\\]|\\*\\d*)?\\s*[:\\uFF1A]\\s*`,
"i",
);
}