Skip to content

Prompt format string for literal backslash#1709

Merged
rolandwalker merged 1 commit intomainfrom
RW/literal-backslash-prompt-escape
Mar 16, 2026
Merged

Prompt format string for literal backslash#1709
rolandwalker merged 1 commit intomainfrom
RW/literal-backslash-prompt-escape

Conversation

@rolandwalker
Copy link
Contributor

Description

In case the user wanted to write a literal \h for some reason, that was previously not possible.

This still doesn't work right for \x, since that is interpreted later, something we can address by unifying.

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

In case the user wanted to write a literal "\h" for some reason, that
was previously not possible.

This still doesn't work right for "\x", since that is interpreted
later, something we can address by unifying.
@rolandwalker rolandwalker self-assigned this Mar 13, 2026
@github-actions
Copy link

  1. Correctness (edge-case regression): mycli/main.py:1705 introduces a fixed sentinel ('\ufffc_backslash') and later blindly converts it back to \ at :1726.
    If a user’s prompt literally contains that substring, it will be mutated unexpectedly.
    Action: use a collision-safe strategy (e.g., generate a per-call unique sentinel not present in the input, or parse escapes without placeholder substitution).

  2. Missing test coverage: this PR changes prompt parsing logic but adds only config comments (test/myclirc:125); no executable tests verify the new behavior.
    Action: add tests in test/test_main.py for:

  • escaped token stays literal ("\\\\h" -> "\h")
  • plain literal backslash ("\\\\" -> "\\")
  • mixed escaped + real tokens (e.g., "\\\\h \\h")

No security concerns found in the introduced changes.

@rolandwalker rolandwalker merged commit 461344b into main Mar 16, 2026
10 checks passed
@rolandwalker rolandwalker deleted the RW/literal-backslash-prompt-escape branch March 16, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants