]> nmode's Git Repositories - signal-cli/commitdiff
Change content-type check to check contains
authorcedb <cedb@keylimebox.org>
Sat, 7 Jan 2023 22:46:07 +0000 (17:46 -0500)
committerAsamK <asamk@gmx.de>
Fri, 3 Mar 2023 17:11:56 +0000 (18:11 +0100)
So far it was doing an equals check, but a string like "application/json; charset=utf-8"
is similarly valid. And some clients like OkHttp actually automatically add the
charset.

Closes #1152

src/main/java/org/asamk/signal/http/HttpServerHandler.java

index a62139291e36e1394e02698682c1536bd6a14fca..f7d06b154dd73e7950979a832b9c4113b53b910b 100644 (file)
@@ -89,7 +89,8 @@ public class HttpServerHandler {
             return;
         }
 
             return;
         }
 
-        if (!"application/json".equals(httpExchange.getRequestHeaders().getFirst("Content-Type"))) {
+        final var contentType = httpExchange.getRequestHeaders().getFirst("Content-Type");
+        if (contentType == null || !contentType.startsWith("application/json")) {
             sendResponse(415, null, httpExchange);
             return;
         }
             sendResponse(415, null, httpExchange);
             return;
         }