[
https://issues.apache.org/jira/browse/GROOVY-12233?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18101567#comment-18101567
]
ASF GitHub Bot commented on GROOVY-12233:
-----------------------------------------
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.
> StringEscapeUtils.unescapeJava mis-decodes and silently drops malformed \u
> escapes
> ----------------------------------------------------------------------------------
>
> Key: GROOVY-12233
> URL: https://issues.apache.org/jira/browse/GROOVY-12233
> Project: Groovy
> Issue Type: Bug
> Reporter: Paul King
> Assignee: Paul King
> Priority: Major
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)