Commit 550b3869 authored by Edward's avatar Edward Committed by Wouter van Oortmerssen

Update Utf8.java: more detailed exception message (#5421)

Provide more detailed exception message for malformed 2 byte utf8 character
parent 5479adc8
...@@ -110,9 +110,11 @@ public abstract class Utf8 { ...@@ -110,9 +110,11 @@ public abstract class Utf8 {
throws IllegalArgumentException { throws IllegalArgumentException {
// Simultaneously checks for illegal trailing-byte in leading position (<= '11000000') and // Simultaneously checks for illegal trailing-byte in leading position (<= '11000000') and
// overlong 2-byte, '11000001'. // overlong 2-byte, '11000001'.
if (byte1 < (byte) 0xC2 if (byte1 < (byte) 0xC2) {
|| isNotTrailingByte(byte2)) { throw new IllegalArgumentException("Invalid UTF-8: Illegal leading byte in 2 bytes utf");
throw new IllegalArgumentException("Invalid UTF-8"); }
if (isNotTrailingByte(byte2)) {
throw new IllegalArgumentException("Invalid UTF-8: Illegal trailing byte in 2 bytes utf");
} }
resultArr[resultPos] = (char) (((byte1 & 0x1F) << 6) | trailingByteValue(byte2)); resultArr[resultPos] = (char) (((byte1 & 0x1F) << 6) | trailingByteValue(byte2));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment