From 2c571f99ab78e7f32b68a16699421a30cfda1888 Mon Sep 17 00:00:00 2001 From: ZypherusKhan <188088240+ZypherusKhan@users.noreply.github.com> Date: Sun, 24 May 2026 22:38:02 +0530 Subject: [PATCH] Fix Template System Regex And Minor Improvements (#620) * Fix regex escape bug * Add logging for missing resource * Clear regex cache --- Modules/TemplateManager.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Modules/TemplateManager.cs b/Modules/TemplateManager.cs index c0f131b0b..c66d32331 100644 --- a/Modules/TemplateManager.cs +++ b/Modules/TemplateManager.cs @@ -205,7 +205,11 @@ public static class TemplateManager private static string GetResourcesTxt(string path) { Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path); - if (stream == null) return string.Empty; + if (stream == null) + { + Logger.Error($"Embedded Resource not found: {path}", "TemplateManager"); + return string.Empty; + } stream.Position = 0; using StreamReader reader = new(stream, Encoding.UTF8); return reader.ReadToEnd(); @@ -237,7 +241,7 @@ public static class TemplateManager """, RegexOptions.IgnoreCase); if (m.Success) { - value = Regex.Unescape(m.Groups[1].Value); + value = m.Groups[1].Value; remaining = (input[..m.Index] + input[(m.Index + m.Length)..]).Trim(',').Trim(); return remaining; } @@ -392,6 +396,7 @@ public static class TemplateManager _cachedEntries = null; _cachedTags = null; _cachedUserVars = null; + RegexCache.Clear(); } private static (Dictionary> Entries, HashSet Tags, Dictionary UserVars) GetParsedFile()