From dad997da75fbccdad4988cea9ce9147f72b493a6 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 26 Oct 2026 20:04:59 -0500 Subject: drop junk after the semicolon --- src/slskd/Common/Middleware/HTMLInjectionMiddleware.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/slskd/Common/Middleware/HTMLInjectionMiddleware.cs') diff --git a/src/slskd/Common/Middleware/HTMLInjectionMiddleware.cs b/src/slskd/Common/Middleware/HTMLInjectionMiddleware.cs index f14307c8..4f3a743b 100644 --- a/src/slskd/Common/Middleware/HTMLInjectionMiddleware.cs +++ b/src/slskd/Common/Middleware/HTMLInjectionMiddleware.cs @@ -130,18 +130,9 @@ namespace slskd context.Response.Headers.Add(header); } - // check the response content type to make sure it's still injectable. the server might return something other - // than what was requested. if it's no longer injectable, don't inject. - var isInjectableResponseType = injectableTypes.Any(injectableType => context.Response.Headers.ContentType.Contains(injectableType)); - if (!isInjectableResponseType) - { - await context.Response.WriteAsync(body); - } - else - { - await context.Response.WriteAsync(body + HTML); - } - } + // drop the semicolon and everything after it (e.g. '; charset=utf-8') before comparing + var responseType = context.Response.ContentType?.Split(';')[0].Trim(); + var isInjectableResponseType = injectableTypes.Contains(responseType, StringComparer.InvariantCultureIgnoreCase); // rewind the stream we injected to the beginning, then replay the data to the // original stream -- cgit v1.2.3