Skip to content

Prompt format string for literal backslash#1709

Open
rolandwalker wants to merge 1 commit intomainfrom
RW/literal-backslash-prompt-escape
Open

Prompt format string for literal backslash#1709
rolandwalker wants to merge 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.

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.

1 participant