File tree Expand file tree Collapse file tree 1 file changed +5
-14
lines changed Expand file tree Collapse file tree 1 file changed +5
-14
lines changed Original file line number Diff line number Diff line change @@ -191,30 +191,21 @@ public static String toString(JSONObject jo) throws JSONException {
191191 * @return The unescaped string.
192192 */
193193 public static String unescape (String string ) {
194- int i = 0 ;
195194 int length = string .length ();
196195 StringBuilder sb = new StringBuilder (length );
197-
198- while (i < length ) {
196+ for (int i = 0 ; i < length ; ++i ) {
199197 char c = string .charAt (i );
200198 if (c == '+' ) {
201- sb .append (' ' );
202- i ++;
199+ c = ' ' ;
203200 } else if (c == '%' && i + 2 < length ) {
204201 int d = JSONTokener .dehexchar (string .charAt (i + 1 ));
205202 int e = JSONTokener .dehexchar (string .charAt (i + 2 ));
206-
207203 if (d >= 0 && e >= 0 ) {
208- sb .append ((char )(d * 16 + e ));
209- i += 3 ;
210- } else {
211- sb .append (c );
212- i ++;
204+ c = (char )(d * 16 + e );
205+ i += 2 ;
213206 }
214- } else {
215- sb .append (c );
216- i ++;
217207 }
208+ sb .append (c );
218209 }
219210 return sb .toString ();
220211 }
You can’t perform that action at this time.
0 commit comments