Skip to content

fix(inbound): preserve literal backslash-n sequences in Windows paths#11547

Merged
steipete merged 3 commits intoopenclaw:mainfrom
mcaxtr:fix/7968-windows-path-newlines
Feb 13, 2026
Merged

fix(inbound): preserve literal backslash-n sequences in Windows paths#11547
steipete merged 3 commits intoopenclaw:mainfrom
mcaxtr:fix/7968-windows-path-newlines

Conversation

@mcaxtr
Copy link
Contributor

@mcaxtr mcaxtr commented Feb 8, 2026

Summary

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

Root Cause

The function had .replaceAll("\\n", "\n") which converted literal backslash-n sequences to newlines. While the intent was to normalize escaped newlines, this also corrupted:

  • Windows paths: C:\Work\nxxxC:\Work<newline>xxx
  • Any user input containing literal \n sequences

Fix

Removed the .replaceAll("\\n", "\n") operation. The function now only normalizes actual newline characters (CRLF and CR to LF), preserving literal backslash-n sequences.

Test Plan

  • Added 6 new tests in inbound-text.test.ts covering Windows path preservation
  • Added test case in inbound.test.ts for finalizeInboundContext with Windows paths
  • Updated existing tests to reflect correct behavior
  • All 5391 tests pass (TDD: 4 tests failed before fix, pass after)
  • Full CI gate passes (pnpm build && pnpm check && pnpm test)

Fixes #7968

Greptile Overview

Greptile Summary

This PR updates normalizeInboundTextNewlines() to only normalize actual newline characters (CRLF/CR → LF) and stop converting literal \\n sequences into real newlines. This prevents Windows paths like C:\\Work\\nxxx\\README.md from being corrupted when sent through the WebUI.

Tests were updated/added to cover both direct calls to normalizeInboundTextNewlines() and the finalizeInboundContext() flow, ensuring CRLF normalization still works while preserving literal backslash-n sequences in paths and messages.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The change is narrowly scoped (removes a single problematic replacement), matches the stated root cause, and is backed by targeted unit tests covering both normalization and context finalization. No call sites appear to rely on converting literal \\n into newlines, and the remaining CRLF/CR normalization behavior is preserved.
  • No files require special attention

@mcaxtr mcaxtr force-pushed the fix/7968-windows-path-newlines branch 2 times, most recently from 88f4922 to 314df41 Compare February 12, 2026 04:18
@mcaxtr mcaxtr force-pushed the fix/7968-windows-path-newlines branch from 079cb94 to 6931752 Compare February 13, 2026 02:29
@openclaw-barnacle openclaw-barnacle bot added the trusted-contributor Contributor with 4+ merged PRs label Feb 13, 2026
@mcaxtr mcaxtr force-pushed the fix/7968-windows-path-newlines branch from 6931752 to 3b0ba41 Compare February 13, 2026 14:45
@openclaw-barnacle openclaw-barnacle bot added the experienced-contributor Contributor with 10+ merged PRs label Feb 13, 2026
@mcaxtr mcaxtr force-pushed the fix/7968-windows-path-newlines branch 2 times, most recently from a7dabf3 to 9885be5 Compare February 13, 2026 16:20
mcaxtr and others added 3 commits February 13, 2026 18:20
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 openclaw#7968
@steipete steipete force-pushed the fix/7968-windows-path-newlines branch from 9885be5 to 64b63d9 Compare February 13, 2026 17:21
@steipete steipete merged commit d91e995 into openclaw:main Feb 13, 2026
9 checks passed
@steipete
Copy link
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm check, pnpm build, pnpm test (full pass before rebase), plus post-rebase targeted regression tests:
    • pnpm test src/auto-reply/inbound.test.ts src/auto-reply/reply/inbound-text.test.ts
  • Land commit: 64b63d9
  • Merge commit: d91e995

Thanks @mcaxtr!

@mcaxtr mcaxtr deleted the fix/7968-windows-path-newlines branch February 13, 2026 18:25
zhangyang-crazy-one pushed a commit to zhangyang-crazy-one/openclaw that referenced this pull request Feb 13, 2026
…openclaw#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 openclaw#7968

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

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

---------

Co-authored-by: Peter Steinberger <[email protected]>
steipete added a commit to azade-c/openclaw that referenced this pull request Feb 14, 2026
…openclaw#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 openclaw#7968

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

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

---------

Co-authored-by: Peter Steinberger <[email protected]>
GwonHyeok pushed a commit to learners-superpumped/openclaw that referenced this pull request Feb 15, 2026
…openclaw#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 openclaw#7968

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

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

---------

Co-authored-by: Peter Steinberger <[email protected]>
cloud-neutral pushed a commit to cloud-neutral-toolkit/openclawbot.svc.plus that referenced this pull request Feb 15, 2026
…openclaw#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 openclaw#7968

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

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

---------

Co-authored-by: Peter Steinberger <[email protected]>
jiulingyun added a commit to jiulingyun/openclaw-cn that referenced this pull request Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experienced-contributor Contributor with 10+ merged PRs size: S trusted-contributor Contributor with 4+ merged PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Windows Paths with \n Sequences Are Corrupted When Sent from WebUI

2 participants

Comments