← Back to Pull requests

Reject malformed Unicode escape sequences #1176

Open
ydah opened this pull request with 37 lines diff across 2 files
View on GitHub
ydah ydah commented on Oct 01, 2026 03:47 UTC
Author

String_ only matches complete hexadecimal Unicode escapes, leaving malformed sequences as literal text instead of reporting an error:

String_::parse('"\u{zz}"'); // Before: literal \u{zz}
String_::parse('"\u{}"');   // Before: literal \u{}
// After: both throw PhpParser\Error("Invalid UTF-8 codepoint escape sequence")

Also match the \u{ prefix and reject it when no complete hexadecimal escape was captured. This catches invalid digits, empty escapes, and missing closing braces.

Diff: 37 lines (+36 / -1) across 2 files Reviewer: nikic Review duration: 5940m
All Vouch review confidence checks passed
Residual risk 0.03 = Change Risk (0.26) × (1 − Review Confidence (0.88)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.26 · 37 lines diff across 2 files
0.26
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.91 · 2 substantive comment(s)
0.91
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
87%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.218
Real PR Conversation Timeline
3 items
nikic nikic commented on code on Oct 04, 2026 15:30 UTC
Code Review
test/code/parser/scalar/unicodeEscape.test:1
@@ -86,3 +86,47 @@ Invalid UTF-8 codepoint escape sequence: Codepoint too large on line 2
 "\u{110000}";
 -----
 Invalid UTF-8 codepoint escape sequence: Codepoint too large on line 2
+-----
+<?php
+"\u{zz}";
+-----
+Invalid UTF-8 codepoint escape sequence on line 2
+-----
+<?php
+"\u{}";
+-----
+Invalid UTF-8 codepoint escape sequence on line 2
+-----
+<?php
+"\u{4z}";
+-----
+Invalid UTF-8 codepoint escape sequence on line 2
+-----
+<?php
+"\u{41";
+-----
+Invalid UTF-8 codepoint escape sequence on line 2

Probably worth testing "\u{" as well, as the minimal invalid sequence?

On the other hand, I'd drop the tests with variables below -- at least it's not obvious to me what extra coverage they are adding.

ydah ydah commented on code on Oct 05, 2026 06:15 UTC
Code Review
test/code/parser/scalar/unicodeEscape.test:1
@@ -86,3 +86,47 @@ Invalid UTF-8 codepoint escape sequence: Codepoint too large on line 2
 "\u{110000}";
 -----
 Invalid UTF-8 codepoint escape sequence: Codepoint too large on line 2
+-----
+<?php
+"\u{zz}";
+-----
+Invalid UTF-8 codepoint escape sequence on line 2
+-----
+<?php
+"\u{}";
+-----
+Invalid UTF-8 codepoint escape sequence on line 2
+-----
+<?php
+"\u{4z}";
+-----
+Invalid UTF-8 codepoint escape sequence on line 2
+-----
+<?php
+"\u{41";
+-----
+Invalid UTF-8 codepoint escape sequence on line 2

Thank you. Added a test for \u{ and removed the cases with variables as suggested.

Reviewers
Assignees
ydah ydah
Labels
risk: low confidence: 87.6% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 26.2% (LOW) · Higher = larger blast radius
26.2%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 87.6% · Lower = rushed or shallow review
87.6%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 3.2% · Safe to merge
3.2%