Skip to content

Commit ac65ee0

Browse files
committed
Revert "Refactored stop conditions to be invariant by using while loop."
This issue can be ignored
1 parent 39e8ead commit ac65ee0

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

src/main/java/org/json/Cookie.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)