You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2026/06/23 12:17:31 UTC
svn commit: r1935582 - in xmlbeans/trunk/src: main/java/org/apache/xmlbeans/impl/regex test/java/misc/checkin
Author: fanningpj
Date: Tue Jun 23 12:17:31 2026
New Revision: 1935582
Log:
use correct error key for out of range hex escape. Thanks to aizu-m. This closes #68
Modified:
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/regex/RegexParser.java
xmlbeans/trunk/src/test/java/misc/checkin/RegularExpressionTest.java
Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/regex/RegexParser.java
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/regex/RegexParser.java Tue Jun 23 12:10:03 2026 (r1935581)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/impl/regex/RegexParser.java Tue Jun 23 12:17:31 2026 (r1935582)
@@ -1054,7 +1054,7 @@ class RegexParser {
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;
}
Modified: xmlbeans/trunk/src/test/java/misc/checkin/RegularExpressionTest.java
==============================================================================
--- xmlbeans/trunk/src/test/java/misc/checkin/RegularExpressionTest.java Tue Jun 23 12:10:03 2026 (r1935581)
+++ xmlbeans/trunk/src/test/java/misc/checkin/RegularExpressionTest.java Tue Jun 23 12:17:31 2026 (r1935582)
@@ -47,6 +47,20 @@ public class RegularExpressionTest {
}
@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
// accumulator. the only guard was a post-multiply min<0/max<0 check, so
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org