From 6ca0237a10dd8f5f895cd491f8605bc929231a53 Mon Sep 17 00:00:00 2001 From: Sebastian Brookfield Date: Fri, 4 Aug 2017 23:51:46 +0100 Subject: [PATCH] #94 Fixed issue where parsing font values with trailing commas causes an IndexOutOfRangeException. --- Source/HtmlRenderer/Core/Parse/CssParser.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/HtmlRenderer/Core/Parse/CssParser.cs b/Source/HtmlRenderer/Core/Parse/CssParser.cs index 045cbb687..cb6ef8975 100644 --- a/Source/HtmlRenderer/Core/Parse/CssParser.cs +++ b/Source/HtmlRenderer/Core/Parse/CssParser.cs @@ -625,9 +625,10 @@ private static string ParseImageProperty(string propValue) private string ParseFontFamilyProperty(string propValue) { int start = 0; - while (start > -1 && start < propValue.Length) + + while (start < propValue.Length) { - while (char.IsWhiteSpace(propValue[start]) || propValue[start] == ',' || propValue[start] == '\'' || propValue[start] == '"') + while (start < propValue.Length && (char.IsWhiteSpace(propValue[start]) || propValue[start] == ',' || propValue[start] == '\'' || propValue[start] == '"')) start++; var end = propValue.IndexOf(',', start); if (end < 0) @@ -639,9 +640,7 @@ private string ParseFontFamilyProperty(string propValue) var font = propValue.Substring(start, adjEnd - start + 1); if (_adapter.IsFontExists(font)) - { return font; - } start = end; }