diff options
| author | David Ullmer <davidullmer@outlook.de> | 2021-08-10 14:03:21 +0200 |
|---|---|---|
| committer | David Ullmer <davidullmer@outlook.de> | 2021-08-10 14:03:21 +0200 |
| commit | 45e0f7893ba8f53827983109557447d2c0c8adcf (patch) | |
| tree | 05ba6fec826a6bcf4cdb17aa1ccfa6939358052c /Jellyfin.Server/Middleware/QueryStringDecodingMiddleware.cs | |
| parent | b5880c26808a6d7f183acb3f7977b42e13ccbf8a (diff) | |
| parent | 854bb79ae8b1e7004c731939e54e52ef937abe47 (diff) | |
Merge remote-tracking branch 'upstream/master' into localization-test
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); + } + } +} |
