From a1f4928ed589541f47ae1daa9b9163a543030d04 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 6 Mar 2017 14:28:04 -0800 Subject: [PATCH] Clean up Header qvalue parsing --- src/Microsoft.Net.Http.Headers/HeaderUtilities.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.Net.Http.Headers/HeaderUtilities.cs b/src/Microsoft.Net.Http.Headers/HeaderUtilities.cs index 64cb5d5705..9f49ba742c 100644 --- a/src/Microsoft.Net.Http.Headers/HeaderUtilities.cs +++ b/src/Microsoft.Net.Http.Headers/HeaderUtilities.cs @@ -13,7 +13,7 @@ namespace Microsoft.Net.Http.Headers public static class HeaderUtilities { private static readonly int _int64MaxStringLength = 19; - private static readonly int _qualityValueMaxCharCount = 10; // Little bit more permissive than RFC7231 5.3.1 + private static readonly int _qualityValueMaxCharCount = 10; // Little bit more permissive than RFC7231 5.3.1 private const string QualityName = "q"; internal const string BytesUnit = "bytes"; @@ -503,7 +503,7 @@ namespace Microsoft.Net.Http.Headers var ch = input[current]; - if (ch >= '0' && ch <= '1') // Only values between 0 and 1 are accepted, according to RFC + if (ch >= '0' && ch <= '1') // Only values between 0 and 1 are accepted, according to RFC { intPart = ch - '0'; current++; @@ -560,8 +560,10 @@ namespace Microsoft.Net.Http.Headers quality = intPart; } - if (quality < 0 || quality > 1) + if (quality > 1) { + // reset quality + quality = 0; return false; }