diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-10-26 20:04:59 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-10-26 20:04:59 -0500 |
| commit | dad997da75fbccdad4988cea9ce9147f72b493a6 (patch) | |
| tree | 08623ebd13285ab0f0eb89382188f909e9fa35d7 /src/slskd | |
| parent | 79ee67b09c7d0f45ac586c7375ed329f238b93f7 (diff) | |
| download | slskd-dad997da75fbccdad4988cea9ce9147f72b493a6.tar.gz | |
drop junk after the semicolon
Diffstat (limited to 'src/slskd')
| -rw-r--r-- | src/slskd/Common/Middleware/HTMLInjectionMiddleware.cs | 15 |
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 |
