Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55a1d5bd authored by Chalard Jean's avatar Chalard Jean Committed by Android (Google) Code Review
Browse files

Merge "Fix a bug where + before % is ignored" into qt-dev

parents b09eed23 d55f2f3d
Loading
Loading
Loading
Loading
+7 −10
Original line number Original line Diff line number Diff line
@@ -22,6 +22,8 @@ import java.util.List;
import java.util.Locale;
import java.util.Locale;
import java.util.Set;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
/**
 *
 *
@@ -837,15 +839,11 @@ public class UrlQuerySanitizer {
     * @param string the escaped string
     * @param string the escaped string
     * @return the unescaped string.
     * @return the unescaped string.
     */
     */
    private static final Pattern plusOrPercent = Pattern.compile("[+%]");
    public String unescape(String string) {
    public String unescape(String string) {
        // Early exit if no escaped characters.
        final Matcher matcher = plusOrPercent.matcher(string);
        int firstEscape = string.indexOf('%');
        if (!matcher.find()) return string;
        if ( firstEscape < 0) {
        final int firstEscape = matcher.start();
            firstEscape = string.indexOf('+');
            if (firstEscape < 0) {
                return string;
            }
        }


        int length = string.length();
        int length = string.length();


@@ -855,8 +853,7 @@ public class UrlQuerySanitizer {
            char c = string.charAt(i);
            char c = string.charAt(i);
            if (c == '+') {
            if (c == '+') {
                c = ' ';
                c = ' ';
            }
            } else if (c == '%' && i + 2 < length) {
            else if ( c == '%' && i + 2 < length) {
                char c1 = string.charAt(i + 1);
                char c1 = string.charAt(i + 1);
                char c2 = string.charAt(i + 2);
                char c2 = string.charAt(i + 2);
                if (isHexDigit(c1) && isHexDigit(c2)) {
                if (isHexDigit(c1) && isHexDigit(c2)) {