From 9c982349439002b7a436321b181343ff6e801a30 Mon Sep 17 00:00:00 2001 From: Adam Vernier Date: Thu, 8 Apr 2021 14:44:08 -0500 Subject: [PATCH] handle url decode exceptions --- .../koushikdutta/async/http/server/AsyncHttpServer.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServer.java b/AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServer.java index 707102c7..082f6918 100644 --- a/AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServer.java +++ b/AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServer.java @@ -108,7 +108,13 @@ protected AsyncHttpRequestBody onBody(Headers headers) { String statusLine = getStatusLine(); String[] parts = statusLine.split(" "); fullPath = parts[1]; - path = URLDecoder.decode(fullPath.split("\\?")[0]); + try { + path = URLDecoder.decode(fullPath.split("\\?")[0], "UTF-8"); + } catch (Exception x) { + Log.w("AsyncHttpServer", "Request for: " + fullPath + " failed: " + x.getMessage()); + method = ""; + return null; + } method = parts[0]; RouteMatch route = route(method, path); if (route == null)