From 67c8e52423fa675612da57c34e3e1f7a95e109bc Mon Sep 17 00:00:00 2001 From: Jeff Brower Date: Sat, 5 Oct 2019 17:42:25 -0400 Subject: [PATCH] Optimize decodePercent to use StandardCharsets.UTF_8 --- .../java/org/nanohttpd/protocols/http/NanoHTTPD.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/nanohttpd/protocols/http/NanoHTTPD.java b/core/src/main/java/org/nanohttpd/protocols/http/NanoHTTPD.java index 42c21514..7b3f7d62 100644 --- a/core/src/main/java/org/nanohttpd/protocols/http/NanoHTTPD.java +++ b/core/src/main/java/org/nanohttpd/protocols/http/NanoHTTPD.java @@ -41,6 +41,7 @@ import java.net.Socket; import java.net.URL; import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.security.KeyStore; import java.util.ArrayList; import java.util.Enumeration; @@ -476,13 +477,7 @@ protected static Map> decodeParameters(String queryString) * "foo bar" */ public static String decodePercent(String str) { - String decoded = null; - try { - decoded = URLDecoder.decode(str, "UTF8"); - } catch (UnsupportedEncodingException ignored) { - NanoHTTPD.LOG.log(Level.WARNING, "Encoding not supported, ignored", ignored); - } - return decoded; + return URLDecoder.decode(str, StandardCharsets.UTF_8); } public final int getListeningPort() {