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();