MinimumNumberFromRange exception (#222)

* More regex! Bonus is now a keyword for specials

* Regex enhancement, Sort chapters on next/prev chapter to ensure they always in proper order, and don't set JWT on starup when in development mode.

* Fixes KAVITA-H. Check to ensure non numeric characters are not in range string before attempting to parse a float out.
This commit is contained in:
Joseph Milazzo 2021-05-17 09:31:16 -05:00 committed by GitHub
parent 308e2b48a0
commit 77c52717ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -121,6 +121,8 @@ namespace API.Tests.Parser
[InlineData("18-04", 4)]
[InlineData("18-04.5", 4.5)]
[InlineData("40", 40)]
[InlineData("40a-040b", 0)]
[InlineData("40.1_a", 0)]
public void MinimumNumberFromRangeTest(string input, float expected)
{
Assert.Equal(expected, MinimumNumberFromRange(input));

View File

@ -799,6 +799,10 @@ namespace API.Parser
public static float MinimumNumberFromRange(string range)
{
if (!Regex.IsMatch(range, @"^[\d-.]+$"))
{
return (float) 0.0;
}
var tokens = range.Replace("_", string.Empty).Split("-");
return tokens.Min(float.Parse);
}