Revert "Refactored stop conditions to be invariant by using while loop."

This issue can be ignored
This commit is contained in:
md-yasir
2025-10-25 20:32:30 +05:30
parent 39e8ead7cd
commit ac65ee0490

View File

@@ -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();
} }