mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
Fix Template System Regex And Minor Improvements (#620)
* Fix regex escape bug * Add logging for missing resource * Clear regex cache
This commit is contained in:
1 parent
9eddcf30d8
commit
2c571f99ab
1 file changed
+7
-2
@@ -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<string, List<TemplateEntry>> Entries, HashSet<string> Tags, Dictionary<string, string> UserVars) GetParsedFile()
|
||||
|
||||
Reference in new issue
Block a user