All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.muserver.rest.Jaxutils Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
package io.muserver.rest;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static io.muserver.Mutils.urlDecode;

class Jaxutils {

    private static final Pattern encoded = Pattern.compile(".*(?%[0-9A-F][0-9A-F]).*");

    static String leniantUrlDecode(String value) {
        if (!value.contains("%")) {
            return value;
        }
        while (true) {
            Matcher matcher = encoded.matcher(value);
            if (!matcher.matches()) {
                return value;
            }
            String octet = matcher.group("octet");
            value = value.replace(octet, urlDecode(octet));
        }
    }

    private Jaxutils() {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy