Skip to content

Commit

Permalink
Sanitize multi-line default comment
Browse files Browse the repository at this point in the history
Just as we do for explicit comment.

Fixes #308
  • Loading branch information
kzu committed Jun 4, 2024
1 parent 0f4352e commit 117d4b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ThisAssembly.Strings/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public static ResourceArea Load(IEnumerable<XElement> 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("<", "&lt;")
.Replace(">", "&gt;")
.Replace("\r\n", " ").Replace("\n", " ");
Expand Down
4 changes: 4 additions & 0 deletions src/ThisAssembly.Tests/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,8 @@
<data name="Named" xml:space="preserve">
<value>Hello {first}, {last}. Should we call you {first}?</value>
</data>
<data name="WithNewLine" xml:space="preserve">
<value>Hello,
World!</value>
</data>
</root>

0 comments on commit 117d4b4

Please sign in to comment.