Skip to content

Commit 22ccf1b

Browse files
authored
Merge pull request #740 from michael-o/proper-encoding
JSONTokener(InputStream) violates rfc8259#section-8.1 (#739)
2 parents 0578285 + 133c0cc commit 22ccf1b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/org/json/JSONTokener.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.json;
22

33
import java.io.*;
4+
import java.nio.charset.Charset;
45

56
/*
67
Public Domain.
@@ -56,7 +57,7 @@ public JSONTokener(Reader reader) {
5657
* @param inputStream The source.
5758
*/
5859
public JSONTokener(InputStream inputStream) {
59-
this(new InputStreamReader(inputStream));
60+
this(new InputStreamReader(inputStream, Charset.forName("UTF-8")));
6061
}
6162

6263

@@ -120,7 +121,7 @@ public static int dehexchar(char c) {
120121

121122
/**
122123
* Checks if the end of the input has been reached.
123-
*
124+
*
124125
* @return true if at the end of the file and we didn't step back
125126
*/
126127
public boolean end() {
@@ -184,7 +185,7 @@ public char next() throws JSONException {
184185
this.previous = (char) c;
185186
return this.previous;
186187
}
187-
188+
188189
/**
189190
* Get the last character read from the input or '\0' if nothing has been read yet.
190191
* @return the last character read from the input.

0 commit comments

Comments
 (0)