aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-10-26 20:04:59 -0500
committerJP Dillingham <jp@dillingham.me>2026-10-26 20:04:59 -0500
commitdad997da75fbccdad4988cea9ce9147f72b493a6 (patch)
tree08623ebd13285ab0f0eb89382188f909e9fa35d7 /src
parent79ee67b09c7d0f45ac586c7375ed329f238b93f7 (diff)
downloadslskd-dad997da75fbccdad4988cea9ce9147f72b493a6.tar.gz
drop junk after the semicolon
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Common/Middleware/HTMLInjectionMiddleware.cs15
1 files changed, 3 insertions, 12 deletions
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