fix: replace invalid \Z regex anchor and remove redundant pattern
The original PR (#1337) used \Z in a JavaScript regex, which is a Perl/Python/Ruby anchor — JavaScript interprets it as a literal match for the character 'Z', silently truncating expected text containing that letter. Replace with a two-pass approach: try next-key lookahead first, fall back to greedy match to end-of-string. Also remove the redundant `to=all:` pattern in sanitizeForDisplay() since it is a subset of the existing `to=[^:\s]+:` pattern. Add regression tests proving the Z-truncation bug and verifying expected blocks at end-of-section parse correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -237,7 +237,6 @@ function sanitizeForDisplay(text) {
|
||||
|
||||
const protocolLeakPatterns = [
|
||||
/^\s*(?:assistant|user|system)\s+to=[^:\s]+:[^\n]+$/i,
|
||||
/^\s*(?:assistant|user|system)\s+to=all:[^\n]+$/i,
|
||||
/^\s*<\|(?:assistant|user|system)[^|]*\|>\s*$/i,
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user