From 343705345b7aef675e2e0a1aa37d011171b6cf2f Mon Sep 17 00:00:00 2001
From: Patrick Simpson
Date: Wed, 5 Apr 2017 10:55:02 +0200
Subject: [PATCH] [KOE-94] Fixed rendering of & in tree nodes for shared
folders. Fixed encoding of strings in SOAP requests, which caused shared
folders with special characters to fail.
---
.../AcaciaZPushPlugin/Controls/KTreeRenderer.cs | 4 +++-
.../AcaciaZPushPlugin/Controls/KTreeRendererDefault.cs | 3 +--
.../AcaciaZPushPlugin/Controls/KTreeRendererVisualStyles.cs | 3 +--
.../AcaciaZPushPlugin/ZPush/Connect/Soap/SoapSerializer.cs | 3 +--
4 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KTreeRenderer.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KTreeRenderer.cs
index ea2a7d3..436cfbc 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KTreeRenderer.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KTreeRenderer.cs
@@ -29,6 +29,8 @@ namespace Acacia.Controls
{
internal abstract class KTreeRenderer
{
+ protected const TextFormatFlags TEXT_FLAGS = TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.NoPrefix;
+
private Rectangle _clientRect;
private Rectangle _totalRect;
protected KTree _tree;
@@ -79,7 +81,7 @@ namespace Acacia.Controls
}
// Text size
- dimension[KTreeNodeMeasurements.Part.Text] = TextRenderer.MeasureText(graphics, node.Text, _tree.Font);
+ dimension[KTreeNodeMeasurements.Part.Text] = TextRenderer.MeasureText(graphics, node.Text, _tree.Font, Size.Empty, TEXT_FLAGS);
// Control
if (node.Control != null)
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KTreeRendererDefault.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KTreeRendererDefault.cs
index 73d5289..5cf0729 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KTreeRendererDefault.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KTreeRendererDefault.cs
@@ -68,8 +68,7 @@ namespace Acacia.Controls
protected override void RenderNodeText(Graphics graphics, KTreeNode node, Rectangle rect, KTreeNodeMeasurements.Part? highlight)
{
- TextRenderer.DrawText(graphics, node.Text, _tree.Font, rect, GetColor(node, highlight),
- Color.Transparent, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
+ TextRenderer.DrawText(graphics, node.Text, _tree.Font, rect, GetColor(node, highlight), Color.Transparent, TEXT_FLAGS);
}
private Color GetColor(KTreeNode node, KTreeNodeMeasurements.Part? highlight)
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KTreeRendererVisualStyles.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KTreeRendererVisualStyles.cs
index ca595e3..0769696 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KTreeRendererVisualStyles.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KTreeRendererVisualStyles.cs
@@ -143,8 +143,7 @@ namespace Acacia.Controls
{
Color foreColor = GetStyle(node, highlight).GetColor(ColorProperty.TextColor);
- TextRenderer.DrawText(graphics, node.Text, _tree.Font, rect, foreColor, Color.Transparent,
- TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
+ TextRenderer.DrawText(graphics, node.Text, _tree.Font, rect, foreColor, Color.Transparent, TEXT_FLAGS);
}
public override void RenderControlBorder(Graphics graphics, Rectangle rect)
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/Connect/Soap/SoapSerializer.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/Connect/Soap/SoapSerializer.cs
index e02f120..6b3c51a 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/Connect/Soap/SoapSerializer.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/Connect/Soap/SoapSerializer.cs
@@ -202,8 +202,7 @@ namespace Acacia.ZPush.Connect.Soap
public override void Serialize(string name, object value, StringBuilder s)
{
- // TODO: this needs escaping
- s.Append(string.Format("<{0} xsi:type=\"xsd:string\">{1}{0}>", name, value));
+ s.Append(string.Format("<{0} xsi:type=\"xsd:string\">{1}{0}>", name, value.ToString().EncodeXML()));
}
protected override object DeserializeContents(XmlNode node, Type expectedType)