From fbd899cc5052253a09daed34efb4788b5136d13a Mon Sep 17 00:00:00 2001 From: Patrick Simpson Date: Thu, 2 Mar 2017 11:27:39 +0100 Subject: [PATCH] [KOE-70] Added explicit BOM to HTML signature files, to prevent encoding errors --- .../Stubs/OutlookWrappers/SignatureWrapper.cs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/SignatureWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/SignatureWrapper.cs index a64ff85..4df0d00 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/SignatureWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/SignatureWrapper.cs @@ -82,14 +82,27 @@ namespace Acacia.Stubs.OutlookWrappers public void SetContent(string content, ISignatureFormat format) { - string path = GetPath(format, false); - File.WriteAllText(path, content); + WriteContent(content, format, false); } public void SetContentTemplate(string content, ISignatureFormat format) { - string path = GetPath(format, true); - File.WriteAllText(path, content); + WriteContent(content, format, true); + } + + private void WriteContent(string content, ISignatureFormat format, bool isTemplate) + { + string path = GetPath(format, isTemplate); + + if (format == ISignatureFormat.HTML) + { + // [KOE-70] If the html file does not have a BOM, it sometimes gives encoding errors. + File.WriteAllText(path, content, new UTF8Encoding(true)); + } + else + { + File.WriteAllText(path, content); + } } public string GetContentTemplate(ISignatureFormat format)