fix: avoid control regex in handoff diagnostics · openclaw/openclaw@89f7526
shakkernerd
·
2026-05-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -54,10 +54,21 @@ function formatShortDuration(ms: number): string {
|
54 | 54 | } |
55 | 55 | |
56 | 56 | function formatDiagnosticValue(value: string): string { |
57 | | -return value |
58 | | -.replace(/[\u0000-\u001f\u007f]+/gu, " ") |
59 | | -.replace(/\s+/gu, " ") |
60 | | -.trim(); |
| 57 | +let normalized = ""; |
| 58 | +let previousWasSpace = true; |
| 59 | +for (const char of value) { |
| 60 | +const code = char.charCodeAt(0); |
| 61 | +if (code <= 0x1f || code === 0x7f || /\s/u.test(char)) { |
| 62 | +if (!previousWasSpace) { |
| 63 | +normalized += " "; |
| 64 | +previousWasSpace = true; |
| 65 | +} |
| 66 | +continue; |
| 67 | +} |
| 68 | +normalized += char; |
| 69 | +previousWasSpace = false; |
| 70 | +} |
| 71 | +return normalized.trimEnd(); |
61 | 72 | } |
62 | 73 | |
63 | 74 | export function formatGatewayRestartHandoffDiagnostic( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。