File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -70,9 +70,12 @@ private static String getValue(JSONTokener x) throws JSONException {
70
70
c = x .next ();
71
71
if (c == q ) {
72
72
//Handle escaped double-quote
73
- if (x .next () != '\"' )
74
- {
75
- x .back ();
73
+ char nextC = x .next ();
74
+ if (nextC != '\"' ) {
75
+ // if our quote was the end of the file, don't step
76
+ if (nextC > 0 ) {
77
+ x .back ();
78
+ }
76
79
break ;
77
80
}
78
81
}
Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ public char next() throws JSONException {
186
186
187
187
if (c <= 0 ) { // End of stream
188
188
this .eof = true ;
189
- c = 0 ;
189
+ return 0 ;
190
190
}
191
191
}
192
192
this .index += 1 ;
@@ -214,8 +214,11 @@ public char next() throws JSONException {
214
214
public char next (char c ) throws JSONException {
215
215
char n = this .next ();
216
216
if (n != c ) {
217
- throw this .syntaxError ("Expected '" + c + "' and instead saw '" +
218
- n + "'" );
217
+ if (n > 0 ) {
218
+ throw this .syntaxError ("Expected '" + c + "' and instead saw '" +
219
+ n + "'" );
220
+ }
221
+ throw this .syntaxError ("Expected '" + c + "' and instead saw ''" );
219
222
}
220
223
return n ;
221
224
}
Original file line number Diff line number Diff line change @@ -102,7 +102,10 @@ public Object nextContent() throws JSONException {
102
102
}
103
103
sb = new StringBuilder ();
104
104
for (;;) {
105
- if (c == '<' || c == 0 ) {
105
+ if (c == 0 ) {
106
+ return sb .toString ().trim ();
107
+ }
108
+ if (c == '<' ) {
106
109
back ();
107
110
return sb .toString ().trim ();
108
111
}
You can’t perform that action at this time.
0 commit comments