Skip to content

Commit

Permalink
Merge pull request #740 from michael-o/proper-encoding
Browse files Browse the repository at this point in the history
JSONTokener(InputStream) violates rfc8259#section-8.1 (#739)
  • Loading branch information
stleary committed May 28, 2023
2 parents 0578285 + 133c0cc commit 22ccf1b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/org/json/JSONTokener.java
@@ -1,6 +1,7 @@
package org.json;

import java.io.*;
import java.nio.charset.Charset;

/*
Public Domain.
Expand Down Expand Up @@ -56,7 +57,7 @@ public JSONTokener(Reader reader) {
* @param inputStream The source.
*/
public JSONTokener(InputStream inputStream) {
this(new InputStreamReader(inputStream));
this(new InputStreamReader(inputStream, Charset.forName("UTF-8")));
}


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

/**
* 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
*/
public boolean end() {
Expand Down Expand Up @@ -184,7 +185,7 @@ public char next() throws JSONException {
this.previous = (char) c;
return this.previous;
}

/**
* Get the last character read from the input or '\0' if nothing has been read yet.
* @return the last character read from the input.
Expand Down

0 comments on commit 22ccf1b

Please sign in to comment.