From a311ce14880c55f23803d8afb90c6799f9ee6084 Mon Sep 17 00:00:00 2001 From: eocron Date: Mon, 26 Mar 2018 17:19:18 +0300 Subject: [PATCH] Fixed IndexOutOfRange When '}' is last character in 'stylesheet' variable --- Source/HtmlRenderer/Core/Parse/RegexParserUtils.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/HtmlRenderer/Core/Parse/RegexParserUtils.cs b/Source/HtmlRenderer/Core/Parse/RegexParserUtils.cs index 806fca4cf..64e2891d9 100644 --- a/Source/HtmlRenderer/Core/Parse/RegexParserUtils.cs +++ b/Source/HtmlRenderer/Core/Parse/RegexParserUtils.cs @@ -107,9 +107,9 @@ public static string GetCssAtRules(string stylesheet, ref int startIdx) int endIdx = stylesheet.IndexOf('{', startIdx); if (endIdx > -1) { + endIdx++; // to prevent IndexOutOfRangeException at line 113. When '}' is last character in 'stylesheet' variable while (count > 0 && endIdx < stylesheet.Length) { - endIdx++; if (stylesheet[endIdx] == '{') { count++; @@ -118,6 +118,7 @@ public static string GetCssAtRules(string stylesheet, ref int startIdx) { count--; } + endIdx++; } if (endIdx < stylesheet.Length) { @@ -194,4 +195,4 @@ private static Regex GetRegex(string regex) return r; } } -} \ No newline at end of file +}