claude-code - 💡(How to fix) Fix Backslash-escaped whitespace check is too aggressive — flags legitimate paths with spaces [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46736Fetched 2026-04-12 13:34:25
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
1
Timeline (top)
labeled ×4commented ×1

Fix Action

Fix / Workaround

  • Users working in directories with spaces have to confirm nearly every command
  • No workaround exists short of renaming the folder
  • macOS commonly creates paths with spaces (iCloud, Documents, etc.)
  • The check fires even when Claude Code itself generated the escaped path

Code Example

cat /Users/user/Projects/1st\ PATO\ AI\ Hackathon/.gitignore
git -C /Users/user/Projects/1st\ PATO\ AI\ Hackathon status
RAW_BUFFERClick to expand / collapse

Problem

The hardcoded "Contains backslash-escaped whitespace" safety check triggers on every bash command whose path contains spaces — even when the command is completely safe, read-only, and auto-allowed by the user's permission settings.

This means working in any directory with spaces in its name (e.g., ~/Documents/My Project/) triggers a confirmation prompt on virtually every command: git status, cat, ls, reading files, etc. The check bypasses allowedTools rules and auto-allow/sandbox settings, so there is no way to suppress it.

Example

A project at ~/Projects/1st PATO AI Hackathon/ caused dozens of confirmation prompts per session for commands like:

cat /Users/user/Projects/1st\ PATO\ AI\ Hackathon/.gitignore
git -C /Users/user/Projects/1st\ PATO\ AI\ Hackathon status

These are clearly safe — the backslashes are just shell-escaping spaces in a real folder name. The scanner correctly identifies them as "Low risk: No risk — read-only command" but still prompts.

Impact

  • Users working in directories with spaces have to confirm nearly every command
  • No workaround exists short of renaming the folder
  • macOS commonly creates paths with spaces (iCloud, Documents, etc.)
  • The check fires even when Claude Code itself generated the escaped path

Suggestion

Instead of pattern-matching on \<space> blindly, the check could:

  1. Resolve the path first — if the backslash-escaped string resolves to an existing file/directory, it's a legitimate path, not an injection attempt
  2. Respect allowedTools rules — if the user has auto-allowed bash commands (via sandbox mode or explicit patterns), don't override that with a hardcoded check
  3. Only flag when ambiguous — e.g., when the escaped whitespace appears in argument positions where it could split into multiple commands, not in quoted strings or -C flag arguments
  4. Exempt the working directory path — Claude Code knows the CWD; if the backslash-escaped portion matches the project root, it's obviously safe

Environment

  • macOS (Darwin), Claude Code CLI
  • Spaces in directory name: 1st PATO AI Hackathon
  • Permission mode: sandbox with bash auto-allow

extent analysis

TL;DR

Modify the safety check to resolve the path first and respect allowedTools rules to prevent unnecessary confirmation prompts.

Guidance

  • Resolve the path before applying the safety check to determine if the backslash-escaped string is a legitimate path.
  • Update the safety check to respect allowedTools rules and auto-allow settings to prevent overriding user permissions.
  • Consider exempting the working directory path from the safety check if it matches the project root.
  • Review the check's logic to only flag ambiguous cases where escaped whitespace could split into multiple commands.

Example

No code snippet is provided as the issue does not contain explicit code, but the suggested changes can be implemented by modifying the existing safety check logic.

Notes

The suggested changes aim to reduce false positives and respect user permissions, but may require additional testing to ensure they do not introduce security vulnerabilities.

Recommendation

Apply a workaround by modifying the safety check to resolve the path first and respect allowedTools rules, as this approach addresses the root cause of the issue and provides a more targeted solution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Backslash-escaped whitespace check is too aggressive — flags legitimate paths with spaces [1 comments, 2 participants]