Skip to content

Commit

Permalink
Identify classes, lines, methods backported from stleary/JSON-java
Browse files Browse the repository at this point in the history
  • Loading branch information
claireagordon committed Apr 2, 2024
1 parent 6f52f9b commit 6ccc32d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

This software incorporates security patches from the Public Domain repository
https://github.com/stleary/JSON-java
8 changes: 8 additions & 0 deletions org/json/JSONObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ of this software and associated documentation files (the "Software"), to deal
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This class includes security patches from the public domain repository
https://github.com/stleary/JSON-java
*/

import java.io.IOException;
Expand Down Expand Up @@ -168,6 +171,9 @@ public JSONObject(JSONObject jo, String[] names) throws JSONException {

/**
* Construct a JSONObject from a JSONTokener.
*
* This class includes security patches from https://github.com/stleary/JSON-java
*
* @param x A JSONTokener object containing the source string.
* @throws JSONException If there is a syntax error in the source string.
*/
Expand All @@ -187,6 +193,7 @@ public JSONObject(JSONTokener x) throws JSONException {
case '}':
return;
default:
// https://github.com/stleary/JSON-java/pull/772
key = x.nextSimpleValue(c).toString();
}

Expand Down Expand Up @@ -214,6 +221,7 @@ public JSONObject(JSONTokener x) throws JSONException {
if (x.nextClean() == '}') {
return;
}
// https://github.com/stleary/JSON-java/pull/759
if (x.end()) {
throw x.syntaxError("A JSONObject text must end with '}'");
}
Expand Down
33 changes: 33 additions & 0 deletions org/json/JSONTokener.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ of this software and associated documentation files (the "Software"), to deal
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This class includes security patches from the public domain repository
https://github.com/stleary/JSON-java
*/

/**
Expand All @@ -39,6 +42,7 @@ of this software and associated documentation files (the "Software"), to deal
public class JSONTokener {

private int index;
// https://github.com/stleary/JSON-java/blob/master/src/main/java/org/json/JSONTokener.java
private boolean eof;
private Reader reader;
private char lastChar;
Expand All @@ -51,6 +55,7 @@ public class JSONTokener {
* @param reader A reader.
*/
public JSONTokener(Reader reader) {
// https://github.com/stleary/JSON-java/blob/master/src/main/java/org/json/JSONTokener.java
this.eof = false;
this.reader = reader.markSupported() ?
reader : new BufferedReader(reader);
Expand Down Expand Up @@ -80,6 +85,7 @@ public void back() throws JSONException {
}
index -= 1;
useLastChar = true;
// https://github.com/stleary/JSON-java/blob/master/src/main/java/org/json/JSONTokener.java
this.eof = false;
}

Expand All @@ -104,6 +110,14 @@ public static int dehexchar(char c) {
return -1;
}

/**
* Checks if the end of the input has been reached.
*
* From the Public Domain repository
* https://github.com/stleary/JSON-java
*
* @return true if at the end of the file and we didn't step back
*/
public boolean end() {
return eof && !useLastChar;
}
Expand All @@ -112,6 +126,10 @@ public boolean end() {
/**
* Determine if the source string still contains characters that next()
* can consume.
*
* Updated to match the version in the Public Domain repository
* https://github.com/stleary/JSON-java
*
* @return true if not yet at the end of the source.
*/
public boolean more() throws JSONException {
Expand Down Expand Up @@ -145,6 +163,7 @@ public char next() throws JSONException {
}

if (c <= 0) { // End of stream
// https://github.com/stleary/JSON-java/blob/master/src/main/java/org/json/JSONTokener.java
this.eof = true;
this.lastChar = 0;
return 0;
Expand Down Expand Up @@ -175,6 +194,9 @@ public char next(char c) throws JSONException {
/**
* Get the next n characters.
*
* Updated to match the version in the Public Domain repository
* https://github.com/stleary/JSON-java
*
* @param n The number of characters to take.
* @return A string of n characters.
* @throws JSONException
Expand All @@ -191,6 +213,7 @@ public String next(int n) throws JSONException {

while (pos < n) {
buffer[pos] = this.next();
// https://github.com/stleary/JSON-java/pull/759
if (this.end()) {
throw this.syntaxError("Substring bounds error");
}
Expand Down Expand Up @@ -351,6 +374,11 @@ public String nextTo(String delimiters) throws JSONException {
/**
* Get the next value. The value can be a Boolean, Double, Integer,
* JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
*
* Updated to match the version in the Public Domain repository
* https://github.com/stleary/JSON-java and incorporate fixes from
* https://github.com/stleary/JSON-java/pull/772
*
* @throws JSONException If syntax error.
*
* @return An object.
Expand All @@ -370,6 +398,11 @@ public Object nextValue() throws JSONException {
return nextSimpleValue(c);
}

/*
* Split into a separate method from nextValue() to incorporate
* https://github.com/stleary/JSON-java/pull/772 from the
* Public Domain repository https://github.com/stleary/JSON-java
*/
Object nextSimpleValue(char c) throws JSONException {
String s;

Expand Down

0 comments on commit 6ccc32d

Please sign in to comment.