From 4b0df802c492d6b4adc61447cb55b5d9ad5ecd94 Mon Sep 17 00:00:00 2001 From: Patrick Simpson Date: Wed, 5 Apr 2017 10:28:24 +0200 Subject: [PATCH] [KOE-96] Added XML escaping to OOF messages. --- .../AcaciaZPushPlugin/Utils/ActiveSync.cs | 2 +- .../AcaciaZPushPlugin/Utils/StringUtil.cs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/ActiveSync.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/ActiveSync.cs index 625f62c..50ae6a6 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/ActiveSync.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/ActiveSync.cs @@ -266,7 +266,7 @@ namespace Acacia.Utils s.Append("1"); s.Append("Text"); s.Append(""); - s.Append(_value.Message[i].Message); // TODO: escaping + s.Append(_value.Message[i].Message.EncodeXML()); s.Append(""); } } diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/StringUtil.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/StringUtil.cs index 4d4055b..131332b 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/StringUtil.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/StringUtil.cs @@ -77,6 +77,8 @@ namespace Acacia.Utils #endregion + #region XML + public static string ToXMLString(this XmlNode xml) { using (var stringWriter = new StringWriter()) @@ -88,6 +90,13 @@ namespace Acacia.Utils } } + public static string EncodeXML(this string s) + { + return System.Security.SecurityElement.Escape(s); + } + + #endregion + #region Resources