Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ int decodeEscaped() throws ParseException {
if (this.read() != T_CHAR || (v2 = hexChar(this.chardata)) < 0)
throw ex("parser.descape.1", this.offset - 1);
uv2 = uv2 * 16 + v2;
if (uv2 > Token.UTF16_MAX) throw ex("parser.descappe.4", this.offset - 1);
if (uv2 > Token.UTF16_MAX) throw ex("parser.descape.4", this.offset - 1);
c = uv2;
break;
}
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/misc/checkin/RegularExpressionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ void testLookbehindRangeAtInputEnd() {
assertFalse(new RegularExpression("x(?<=[a-c])").matches("xc"));
}

@Test
void testHexEscapeOverflowErrorKey() {
// a \v escape (6 hex digits) whose value is above U+10FFFF was reported with
// the error key "parser.descappe.4", which is not in the message bundle, so
// ResourceBundle.getString threw MissingResourceException instead of the
// ParseException callers expect. The sibling \x{...} path already reports the
// same condition cleanly via "parser.descape.4".
assertThrows(ParseException.class, () -> new RegularExpression("\\v110000"));
assertThrows(ParseException.class, () -> new RegularExpression("\\vFFFFFF"));
assertThrows(ParseException.class, () -> new RegularExpression("\\x{110000}"));
// the top of the Unicode range is still valid and must parse
new RegularExpression("\\v10FFFF");
}

@Test
void testQuantifierOverflow() {
// a {min,max} count larger than Integer.MAX_VALUE overflowed the int
Expand Down