From 68e38d68b50128bf93021eaa8312792e14ebfa14 Mon Sep 17 00:00:00 2001 From: ogchrislem <131682580+ogchrislem@users.noreply.github.com> Date: Mon, 13 May 2024 11:42:13 +0100 Subject: [PATCH] Change Json regex to prevent timeout with partial json Json parsing can fail with incomplete json, and just timeout with no exception thrown. Adding the word boundary match to the regex prevents this. Unsure of any further implications but complete json is still parsed successfully after the change --- ColorCode.Core/Compilation/Languages/Json.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ColorCode.Core/Compilation/Languages/Json.cs b/ColorCode.Core/Compilation/Languages/Json.cs index ab568d9..57f6fae 100644 --- a/ColorCode.Core/Compilation/Languages/Json.cs +++ b/ColorCode.Core/Compilation/Languages/Json.cs @@ -13,7 +13,7 @@ namespace ColorCode.Compilation.Languages /// public class Json : ILanguage { - private const string Regex_String = @"""[^""\\]*(?:\\[^\r\n]|[^""\\]*)*"""; + private const string Regex_String = @"""[^""\\]*(?:\\[^\r\n]|[^""\\\w]*)*"""; private const string Regex_Number = @"-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?"; public string Id