From 3c019d1324c6ec29bf96aab28b94208924bb317f Mon Sep 17 00:00:00 2001 From: Tommaso Stocchi Date: Thu, 3 Jun 2021 17:10:19 +0200 Subject: [PATCH] Using for instead of while --- .../HttpServer/Security/AuthorizationContext.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs index 7a83b72133..26f3b8d68f 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs @@ -276,16 +276,15 @@ namespace Emby.Server.Implementations.HttpServer.Security public static Dictionary GetParts(string authtorizationHeader) { var result = new Dictionary(); - var escapeChars = new[] { '"', ',' }; var escaped = false; int start = 0; - int i = 0; string key = string.Empty; - while (i < authtorizationHeader.Length) + int i; + for (i = 0; i < authtorizationHeader.Length; i++) { var token = authtorizationHeader[i]; - if (escapeChars.Contains(token)) + if (token == '"' || token == ',') { // Applying a XOR logic to evaluate whether it is opening or closing a value escaped = (!escaped) == (token == '"'); @@ -306,8 +305,6 @@ namespace Emby.Server.Implementations.HttpServer.Security key = authtorizationHeader[start.. i]; start = i + 1; } - - i++; } // Add last value