Files
openclaw/src/auto-reply/reply/inbound-text.ts
Marcus Castro d91e995e46 fix(inbound): preserve literal backslash-n sequences in Windows paths (#11547)
* fix(inbound): preserve literal backslash-n sequences in Windows paths

The normalizeInboundTextNewlines function was converting literal backslash-n
sequences (\n) to actual newlines, corrupting Windows paths like
C:\Work\nxxx\README.md when sent through WebUI.

This fix removes the .replaceAll("\\n", "\n") operation, preserving
literal backslash-n sequences while still normalizing actual CRLF/CR to LF.

Fixes #7968

* fix(test): set RawBody to Windows path so BodyForAgent fallback chain tests correctly

* fix: tighten Windows path newline regression coverage (#11547) (thanks @mcaxtr)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-02-13 18:24:01 +01:00

7 lines
360 B
TypeScript

export function normalizeInboundTextNewlines(input: string): string {
// Normalize actual newline characters (CR+LF and CR to LF).
// Do NOT replace literal backslash-n sequences (\\n) as they may be part of
// Windows paths like C:\Work\nxxx\README.md or user-intended escape sequences.
return input.replaceAll("\r\n", "\n").replaceAll("\r", "\n");
}