Copilot commented on code in PR #2763:
URL: https://github.com/apache/groovy/pull/2763#discussion_r3709328950
##########
subprojects/groovy-json/src/main/java/groovy/json/StringEscapeUtils.java:
##########
@@ -318,18 +320,18 @@ public static void unescapeJava(Writer out, String str)
throws IOException {
// if in unicode, then we're reading unicode
// values in somehow
unicode.append(ch);
+ if (!isHexDigit(ch)) {
+ // Integer.parseInt would accept a sign or a non-ASCII
digit here, but an
+ // escape carries exactly four hexadecimal digits and
nothing else
+ throw new JsonException("Unable to parse unicode value: "
+ unicode);
+ }
Review Comment:
The new JsonException message for malformed Unicode escapes can be empty for
inputs like "\\u" (since `unicode` is empty), which makes the error hard to
diagnose. Including the `\\u` prefix (and ideally the partial digits) will make
the message actionable.
This issue also appears on line 383 of the same file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]