Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLDR-17847 Fix NPE in CodePointEscaper #3918

Merged
Merged
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 @@ -228,9 +228,10 @@ public static String toUnescaped(String escaped) {
public static String toExample(int codePoint) {
CodePointEscaper cpe = _fromCodePoint.get(codePoint);
if (cpe == null) { // hex
final String name = UCharacter.getExtendedName(codePoint);
return codePointToEscaped(codePoint)
+ HAS_NAME
+ UCharacter.getName(codePoint).toLowerCase();
+ (name != null ? name.toLowerCase() : "");
} else {
return CodePointEscaper.codePointToEscaped(cpe.codePoint)
+ HAS_NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,19 @@ public void TestStringEscaper() {
assertEquals(expected, expectedRoundtrip, actualRoundtrip);
}
}

public void test17847() {
String path =
"//ldml/characters/parseLenients[@scope=\"general\"][@level=\"lenient\"]/parseLenient[@sample=\"$\"]";
String value = "[\\$$﹩ \\uFFFF]";
UnicodeSet valueSet = new UnicodeSet(value).freeze();
UnicodeSet examples = new UnicodeSet();

// throws exception
if (valueSet.containsSome(CodePointEscaper.FORCE_ESCAPE)) {
for (String nsm : new UnicodeSet(valueSet).retainAll(CodePointEscaper.FORCE_ESCAPE)) {
assertNotNull(Utility.hex(nsm), CodePointEscaper.toExample(nsm.codePointAt(0)));
}
}
}
}
Loading