1
0
mirror of https://github.com/Kopano-dev/kopano-ol-extension.git synced 2023-10-10 13:37:40 +02:00

[KOE-150] Added escaping of special characters in signature names

This commit is contained in:
Patrick Simpson 2018-05-09 15:55:43 +03:00
parent 6ecc15d237
commit 7cd41c6d12
3 changed files with 18 additions and 3 deletions

View File

@ -270,9 +270,9 @@ namespace Acacia.Features.Signatures
if (gab != null) if (gab != null)
ReplacePlaceholders(gab, name); ReplacePlaceholders(gab, name);
} }
}
return name; return signature.Name;
}
} }
private string GetSignatureName(ISignatures signatures, ZPushAccount account, string name) private string GetSignatureName(ISignatures signatures, ZPushAccount account, string name)

View File

@ -18,5 +18,7 @@ namespace Acacia.Stubs
void SetContent(string content, ISignatureFormat format); void SetContent(string content, ISignatureFormat format);
void SetContentTemplate(string content, ISignatureFormat format); void SetContentTemplate(string content, ISignatureFormat format);
string GetContentTemplate(ISignatureFormat format); string GetContentTemplate(ISignatureFormat format);
string Name { get; }
} }
} }

View File

@ -32,6 +32,11 @@ namespace Acacia.Stubs.OutlookWrappers
this._name = name; this._name = name;
} }
public string Name
{
get { return EscapeSignatureName(_name); }
}
protected override void DoRelease() protected override void DoRelease()
{ {
} }
@ -50,7 +55,15 @@ namespace Acacia.Stubs.OutlookWrappers
private static string GetPath(string name, string suffix) private static string GetPath(string name, string suffix)
{ {
return Path.Combine(BasePath, name) + "." + suffix; return Path.Combine(BasePath, EscapeSignatureName(name)) + "." + suffix;
}
private static string EscapeSignatureName(string name)
{
string invalidChars = System.Text.RegularExpressions.Regex.Escape(new string(Path.GetInvalidFileNameChars()));
string invalidRegStr = string.Format(@"([{0}]*\.+$)|([{0}]+)", invalidChars);
return System.Text.RegularExpressions.Regex.Replace(name, invalidRegStr, "_");
} }
public void Delete() public void Delete()