From cdab5151be10b787d1a819bbf1a9032e8784a109 Mon Sep 17 00:00:00 2001 From: GHXX Date: Sat, 13 Jul 2024 06:32:59 +0200 Subject: [PATCH] fix parameter url decoding --- SimpleHttpServer/HttpServer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SimpleHttpServer/HttpServer.cs b/SimpleHttpServer/HttpServer.cs index eff0d0b..a084aa7 100644 --- a/SimpleHttpServer/HttpServer.cs +++ b/SimpleHttpServer/HttpServer.cs @@ -187,14 +187,15 @@ public sealed class HttpServer { private async Task ProcessRequestAsync(HttpListenerContext ctx) { using RequestContext rc = new RequestContext(ctx); - var decUri = WebUtility.UrlDecode(ctx.Request.RawUrl)!; // TODO add path escape countermeasure-unittests - var splitted = decUri.Split('?', 2, StringSplitOptions.None); + + // TODO add path escape countermeasure-unittests + var splitted = (ctx.Request.RawUrl ?? "").Split('?', 2, StringSplitOptions.None); var reqPath = NormalizeUrlPath(WebUtility.UrlDecode(splitted.First())); string requestMethod = ctx.Request.HttpMethod.ToUpperInvariant(); bool wasStaticlyServed = false; void LogRequest() { - requestLogger.Information($"{rc.ListenerContext.Response.StatusCode} {(wasStaticlyServed ? "static" : "endpnt")} {requestMethod} {decUri}"); + requestLogger.Information($"{rc.ListenerContext.Response.StatusCode} {(wasStaticlyServed ? "static" : "endpnt")} {requestMethod} {ctx.Request.Url}"); } try {