Skip to content

fix: reject incomplete \c escape at end of pattern#48

Draft
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-incomplete-control-escape
Draft

fix: reject incomplete \c escape at end of pattern#48
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-incomplete-control-escape

Conversation

@toddr-bot
Copy link
Copy Markdown
Collaborator

What

\c at end of pattern now errors instead of silently producing @ (chr 64).

Why

Perl requires a character after \c and rejects bare \c with "Character following \c must be printable ASCII". The parser's handler used (.?) which matched zero characters at end of string, silently computing chr(64 ^ ord("")) = chr(64) = @.

How

Changed the handler regex from (.?) to (.) and added an error check using RPe_ESLASH when no character follows.

Testing

  • 2 new assertions in t/11errors.t
  • All existing tests pass

🤖 Generated with Claude Code

\c requires a following character (the control character argument).
When \c appeared at end of string, the handler silently produced @
(chr(64)) instead of an error. Perl rejects this as "Character
following \c must be printable ASCII". Now errors with RPe_ESLASH.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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