diff options
| author | Claus Vium <cvium@users.noreply.github.com> | 2021-06-07 23:07:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-07 23:07:59 +0200 |
| commit | 93387ba235fc86861d4cf24c582f49fb33bb0787 (patch) | |
| tree | 5917003d31cf18a4c31a18fd04ec8a9a6f30e749 /Jellyfin.Server/Middleware/QueryStringDecodingMiddleware.cs | |
| parent | 19a18899065aa2d50b0a989911a5f58a368b3b95 (diff) | |
| parent | 147612f59bb5870f04197087e3d5fcd954061471 (diff) | |
Merge pull request #5990 from BaronGreenback/UrlDecoding
Diffstat (limited to 'Jellyfin.Server/Middleware/QueryStringDecodingMiddleware.cs')
| -rw-r--r-- | Jellyfin.Server/Middleware/QueryStringDecodingMiddleware.cs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Jellyfin.Server/Middleware/QueryStringDecodingMiddleware.cs b/Jellyfin.Server/Middleware/QueryStringDecodingMiddleware.cs new file mode 100644 index 000000000..fd0ebbf43 --- /dev/null +++ b/Jellyfin.Server/Middleware/QueryStringDecodingMiddleware.cs @@ -0,0 +1,35 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; + +namespace Jellyfin.Server.Middleware +{ + /// <summary> + /// URL decodes the querystring before binding. + /// </summary> + public class QueryStringDecodingMiddleware + { + private readonly RequestDelegate _next; + + /// <summary> + /// Initializes a new instance of the <see cref="QueryStringDecodingMiddleware"/> class. + /// </summary> + /// <param name="next">The next delegate in the pipeline.</param> + public QueryStringDecodingMiddleware(RequestDelegate next) + { + _next = next; + } + + /// <summary> + /// Executes the middleware action. + /// </summary> + /// <param name="httpContext">The current HTTP context.</param> + /// <returns>The async task.</returns> + public async Task Invoke(HttpContext httpContext) + { + httpContext.Features.Set<IQueryFeature>(new UrlDecodeQueryFeature(httpContext.Features.Get<IQueryFeature>())); + + await _next(httpContext).ConfigureAwait(false); + } + } +} |
