From 85314eb99b538554dafd1f08c28920302e5241f3 Mon Sep 17 00:00:00 2001 From: Boocat-dmc Date: Thu, 28 May 2026 21:48:49 +0200 Subject: [PATCH] Update ImageBuilder.cs --- Services/ImageBuilder.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Services/ImageBuilder.cs b/Services/ImageBuilder.cs index f9a4860..61607b1 100644 --- a/Services/ImageBuilder.cs +++ b/Services/ImageBuilder.cs @@ -76,7 +76,7 @@ public static ConcurrentBag GenerateAll( if (!record.ContainsKey(colName) || record[colName] == null) continue; - string text = record[colName].ToString(); + string text = EscapeMagickText(record[colName].ToString()); if (string.IsNullOrWhiteSpace(text)) continue; var color = MagickColor.FromRgb((byte)fieldCfg.Color[0], (byte)fieldCfg.Color[1], (byte)fieldCfg.Color[2]); @@ -141,6 +141,16 @@ public static ConcurrentBag GenerateAll( return logs; } + private static string EscapeMagickText(string text) +{ + if (string.IsNullOrEmpty(text)) + return string.Empty; + + return text + .Replace("\\", "\\\\") + .Replace("\"", "\\\"") + .Replace("%", "%%"); +} private static string SanitizeFileName(string fileName) { char[] invalidChars = Path.GetInvalidFileNameChars();