io.muserver.rest.Jaxutils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mu-server Show documentation
Show all versions of mu-server Show documentation
A simple but powerful web server framework
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() {
}
}