mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-07 11:10:08 +08:00
Merge pull request #740 from michael-o/proper-encoding
JSONTokener(InputStream) violates rfc8259#section-8.1 (#739)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package org.json;
|
package org.json;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Public Domain.
|
Public Domain.
|
||||||
@@ -56,7 +57,7 @@ public class JSONTokener {
|
|||||||
* @param inputStream The source.
|
* @param inputStream The source.
|
||||||
*/
|
*/
|
||||||
public JSONTokener(InputStream inputStream) {
|
public JSONTokener(InputStream inputStream) {
|
||||||
this(new InputStreamReader(inputStream));
|
this(new InputStreamReader(inputStream, Charset.forName("UTF-8")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ public class JSONTokener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the end of the input has been reached.
|
* Checks if the end of the input has been reached.
|
||||||
*
|
*
|
||||||
* @return true if at the end of the file and we didn't step back
|
* @return true if at the end of the file and we didn't step back
|
||||||
*/
|
*/
|
||||||
public boolean end() {
|
public boolean end() {
|
||||||
@@ -184,7 +185,7 @@ public class JSONTokener {
|
|||||||
this.previous = (char) c;
|
this.previous = (char) c;
|
||||||
return this.previous;
|
return this.previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the last character read from the input or '\0' if nothing has been read yet.
|
* Get the last character read from the input or '\0' if nothing has been read yet.
|
||||||
* @return the last character read from the input.
|
* @return the last character read from the input.
|
||||||
|
Reference in New Issue
Block a user