From 8ad8be7a77ede83534d823b088c8d042fdb365b7 Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Tue, 4 Jun 2024 18:19:43 -0300 Subject: [PATCH] Sanitize multi-line default comment Just as we do for explicit comment. Fixes #308 --- src/ThisAssembly.Strings/Model.cs | 3 ++- src/ThisAssembly.Tests/Resources.resx | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ThisAssembly.Strings/Model.cs b/src/ThisAssembly.Strings/Model.cs index 3693b9f2..f34f306f 100644 --- a/src/ThisAssembly.Strings/Model.cs +++ b/src/ThisAssembly.Strings/Model.cs @@ -51,7 +51,8 @@ public static ResourceArea Load(IEnumerable data, string rootArea) if (valueElement == null) continue; - var comment = element.Element("comment")?.Value? + // Make sure we trim newlines and replace them with spaces for comments. + var comment = (element.Element("comment")?.Value ?? valueElement) .Replace("<", "<") .Replace(">", ">") .Replace("\r\n", " ").Replace("\n", " "); diff --git a/src/ThisAssembly.Tests/Resources.resx b/src/ThisAssembly.Tests/Resources.resx index 5335b067..0c455cce 100644 --- a/src/ThisAssembly.Tests/Resources.resx +++ b/src/ThisAssembly.Tests/Resources.resx @@ -132,4 +132,8 @@ Hello {first}, {last}. Should we call you {first}? + + Hello, +World! + \ No newline at end of file