This is an automated email from the ASF dual-hosted git repository.
rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/johnzon.git
The following commit(s) were added to refs/heads/master by this push:
new 156c7af if we find only one byte and it is 0 then fail the guess
encoding algorithm
156c7af is described below
commit 156c7af77322fc0d11819756fc48fb18bd617b71
Author: Romain Manni-Bucau <[email protected]>
AuthorDate: Mon Aug 19 14:51:11 2019 +0200
if we find only one byte and it is 0 then fail the guess encoding algorithm
---
.../java/org/apache/johnzon/core/RFC4627AwareInputStreamReader.java | 3 +++
1 file changed, 3 insertions(+)
diff --git
a/johnzon-core/src/main/java/org/apache/johnzon/core/RFC4627AwareInputStreamReader.java
b/johnzon-core/src/main/java/org/apache/johnzon/core/RFC4627AwareInputStreamReader.java
index 2fe908e..0fc2784 100644
---
a/johnzon-core/src/main/java/org/apache/johnzon/core/RFC4627AwareInputStreamReader.java
+++
b/johnzon-core/src/main/java/org/apache/johnzon/core/RFC4627AwareInputStreamReader.java
@@ -95,6 +95,9 @@ final class RFC4627AwareInputStreamReader extends
InputStreamReader {
return StandardCharsets.UTF_8; // empty file -> doesn't matter
anyway
}
if (utfBytes.length == 1) {
+ if (utfBytes[0] == 0) { // TCK shortcut since behavior is
doubious
+ throw new JsonException("Unknown encoding");
+ }
inputStream.unread(utfBytes);
return StandardCharsets.UTF_8; // almost empty file -> doesn't
matter neither
}