From 0e334f995d884f9c6989e9c6fed5b41c68c8678c Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Wed, 8 Jan 2025 20:47:15 +0100 Subject: [PATCH] NSString: Use SecurityElement.Escape to escape XML characters --- plist-cil.test/NSStringTests.cs | 29 +++++++++++++++++++++++++++++ plist-cil/NSString.cs | 14 +++----------- 2 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 plist-cil.test/NSStringTests.cs diff --git a/plist-cil.test/NSStringTests.cs b/plist-cil.test/NSStringTests.cs new file mode 100644 index 0000000..380728d --- /dev/null +++ b/plist-cil.test/NSStringTests.cs @@ -0,0 +1,29 @@ +using Claunia.PropertyList; +using Xunit; + +namespace plistcil.test +{ + public class NSStringTests + { + const string START_TOKEN = ""; + const string END_TOKEN = ""; + + [InlineData("abc", "abc")] + [InlineData("a>b", "a>b")] + [InlineData("a character should be escaped. - if(Content.Contains("&") || - Content.Contains("<") || - Content.Contains(">")) - { - xml.Append("", "]]]]>")); - xml.Append("]]>"); - } - else - xml.Append(Content); + xml.Append(SecurityElement.Escape(Content)); xml.Append(""); }