From 38de8b1cf3e0772d98ae76bd3b46620a8d8a2475 Mon Sep 17 00:00:00 2001 From: jonmv Date: Fri, 6 Oct 2023 13:10:45 +0200 Subject: 0xFFFE, 0xFFFF and stand-alone low surrogates are not valid text --- vespajlib/src/main/java/com/yahoo/text/Text.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'vespajlib') diff --git a/vespajlib/src/main/java/com/yahoo/text/Text.java b/vespajlib/src/main/java/com/yahoo/text/Text.java index a2e7a696857..474702a74b3 100644 --- a/vespajlib/src/main/java/com/yahoo/text/Text.java +++ b/vespajlib/src/main/java/com/yahoo/text/Text.java @@ -50,13 +50,12 @@ public final class Text { return (codepoint < 0x80) ? allowedAsciiChars[codepoint] - : (codepoint < Character.MIN_SURROGATE) || isTextCharAboveMinSurrogate(codepoint); + : (codepoint < Character.MIN_SURROGATE) || isTextCharAboveMinSurrogate(codepoint); } private static boolean isTextCharAboveMinSurrogate(int codepoint) { - if (codepoint <= Character.MAX_HIGH_SURROGATE) return false; + if (codepoint <= Character.MAX_SURROGATE) return false; if (codepoint < 0xFDD0) return true; if (codepoint <= 0xFDDF) return false; - if (codepoint < 0x10000) return true; if (codepoint >= 0x10FFFE) return false; return (codepoint & 0xffff) < 0xFFFE; } @@ -75,7 +74,7 @@ public final class Text { if (Character.isHighSurrogate(string.charAt(i))) { if ( charCount == 1) { return OptionalInt.of(string.codePointAt(i)); - } else if ( !Character.isLowSurrogate(string.charAt(i+1))) { + } else if ( ! Character.isLowSurrogate(string.charAt(i+1))) { return OptionalInt.of(string.codePointAt(i+1)); } } -- cgit v1.2.3