Skip to content

fix(regex): reject empty unicode brace escape - #4102

Merged
hackwaly merged 1 commit into
mainfrom
yuxiang/fix-regex-parser
Aug 19, 2026
Merged

fix(regex): reject empty unicode brace escape#4102
hackwaly merged 1 commit into
mainfrom
yuxiang/fix-regex-parser

Conversation

@hackwaly

Copy link
Copy Markdown
Contributor

This PR fix wrong behavior of regex parser, make it reject empty unicode brace escape.

Copilot AI lite review requested due to automatic review settings August 19, 2026 05:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens the regex parser’s escape handling so that an empty Unicode brace escape (\u{}) is rejected as an invalid escape sequence, rather than being partially parsed as literal characters (notably inside character classes).

Changes:

  • Reject stray \u prefixes in both character-class parsing (class_atom) and general term parsing (term) by raising HINT_INVALID_ESCAPE when they don’t match a valid \uXXXX or \u{X...} form.
  • Add a regression test ensuring [\u{}] fails with ParserError(..., hint="Invalid escape sequence").

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
string/internal/regex_parser/parser.mbt Adds explicit rejection of invalid/partial \u escape sequences to prevent \u{} from being mis-parsed.
string/internal/regex_parser/parser_test.mbt Adds a test case covering the newly rejected empty Unicode brace escape inside a character class.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 6165

Coverage decreased (-0.004%) to 90.682%

Details

  • Coverage decreased (-0.004%) from the base build.
  • Patch coverage: 1 uncovered change across 1 file (1 of 2 lines covered, 50.0%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
string/internal/regex_parser/parser.mbt 2 1 50.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 17900
Covered Lines: 16232
Line Coverage: 90.68%
Coverage Strength: 332092.66 hits per line

💛 - Coveralls

@hackwaly
hackwaly merged commit 99f83da into main Aug 19, 2026
14 of 20 checks passed
@hackwaly
hackwaly deleted the yuxiang/fix-regex-parser branch August 19, 2026 05:30
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.

3 participants