mirror of
https://github.com/stleary/JSON-java.git
synced 2026-01-24 00:03:17 -05:00
Revert "Refactored stop conditions to be invariant by using while loop."
This issue can be ignored
This commit is contained in:
@@ -191,30 +191,21 @@ public class Cookie {
|
|||||||
* @return The unescaped string.
|
* @return The unescaped string.
|
||||||
*/
|
*/
|
||||||
public static String unescape(String string) {
|
public static String unescape(String string) {
|
||||||
int i = 0;
|
|
||||||
int length = string.length();
|
int length = string.length();
|
||||||
StringBuilder sb = new StringBuilder(length);
|
StringBuilder sb = new StringBuilder(length);
|
||||||
|
for (int i = 0; i < length; ++i) {
|
||||||
while (i < length) {
|
|
||||||
char c = string.charAt(i);
|
char c = string.charAt(i);
|
||||||
if (c == '+') {
|
if (c == '+') {
|
||||||
sb.append(' ');
|
c = ' ';
|
||||||
i++;
|
|
||||||
} else if (c == '%' && i + 2 < length) {
|
} else if (c == '%' && i + 2 < length) {
|
||||||
int d = JSONTokener.dehexchar(string.charAt(i + 1));
|
int d = JSONTokener.dehexchar(string.charAt(i + 1));
|
||||||
int e = JSONTokener.dehexchar(string.charAt(i + 2));
|
int e = JSONTokener.dehexchar(string.charAt(i + 2));
|
||||||
|
|
||||||
if (d >= 0 && e >= 0) {
|
if (d >= 0 && e >= 0) {
|
||||||
sb.append((char)(d * 16 + e));
|
c = (char)(d * 16 + e);
|
||||||
i += 3;
|
i += 2;
|
||||||
} else {
|
|
||||||
sb.append(c);
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
sb.append(c);
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
sb.append(c);
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user