mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[cidr debugger] CPP-40257 handle invalid codepoints during escape sequence decoding
GitOrigin-RevId: 57063d148b5d840f17e08b664d70c949636b5b1b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
838ffe3ee6
commit
43a7345a5c
@@ -874,11 +874,16 @@ public class StringUtil {
|
||||
}
|
||||
if (sb.length() != 0) {
|
||||
try {
|
||||
long code = Long.parseLong(sb.toString(), radix);
|
||||
//noinspection AssignmentToForLoopParameter
|
||||
idx += sb.length() + suffixLen - 1;
|
||||
// todo: implement UTF-32 support
|
||||
buffer.append((char)code);
|
||||
int code = Integer.parseInt(sb.toString(), radix);
|
||||
if (Character.isValidCodePoint(code)) {
|
||||
//noinspection AssignmentToForLoopParameter
|
||||
idx += sb.length() + suffixLen - 1;
|
||||
// todo: implement UTF-32 support
|
||||
buffer.append(Character.toChars(code));
|
||||
}
|
||||
else {
|
||||
buffer.append('\\').append(ch);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
buffer.append('\\').append(ch);
|
||||
|
||||
@@ -1077,11 +1077,13 @@ public class StringUtilTest {
|
||||
assertEquals("" + (char)0xfff, StringUtil.unescapeAnsiStringCharacters("\\xfff"));
|
||||
assertEquals("" + (char)0xffff, StringUtil.unescapeAnsiStringCharacters("\\xffff"));
|
||||
assertEquals("" + (char)0xf, StringUtil.unescapeAnsiStringCharacters("\\x0000000000000000f"));
|
||||
assertEquals("\\x110000", StringUtil.unescapeAnsiStringCharacters("\\x110000")); // invalid unicode codepoint
|
||||
|
||||
// 4 digit codepoint
|
||||
assertEquals("\u1234", StringUtil.unescapeAnsiStringCharacters("\\u1234"));
|
||||
|
||||
// 8 digit codepoint
|
||||
assertEquals("\u0061", StringUtil.unescapeAnsiStringCharacters("\\U00000061"));
|
||||
assertEquals("\\U00110000", StringUtil.unescapeAnsiStringCharacters("\\U00110000")); // invalid unicode codepoint
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user