Commit edc594e1 authored by davescriven's avatar davescriven
Browse files

- Fixed [workitem:7526] whitespaces \t \r \n in path and points result in...

- Fixed [workitem:7526] whitespaces \t \r \n in path and points result in exception. The   SvgUnitCollectionConverter (SvgUnitCollection.cs) class had to split on \r, \t and \n aswell as ' ' and ','.
parent 773803a4
......@@ -46,9 +46,9 @@ namespace Svg
}
}
}
catch
catch (Exception exc)
{
Trace.TraceError("Error rendering points.");
Trace.TraceError("Error rendering points: " + exc.Message);
}
this.IsPathDirty = false;
}
......
......@@ -34,7 +34,7 @@ namespace Svg
{
if (value is string)
{
string[] points = ((string)value).Split(new char[]{',', ' '}, StringSplitOptions.RemoveEmptyEntries);
string[] points = ((string)value).Trim().Split(new char[] { ',', ' ', '\r', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
SvgUnitCollection units = new SvgUnitCollection();
foreach (string point in points)
......
......@@ -26,7 +26,7 @@ namespace Svg
// http://www.w3.org/TR/CSS21/syndata.html#values
// http://www.w3.org/TR/SVG11/coords.html#Units
string unit = value as string;
string unit = (string)value;
int identifierIndex = -1;
for (int i = 0; i < unit.Length; i++)
......
......@@ -32,7 +32,7 @@ namespace Svg
foreach (var commandSet in SplitCommands(path.TrimEnd(null)))
{
coords = new List<float>(ParseCoordinates(commandSet));
coords = new List<float>(ParseCoordinates(commandSet.Trim()));
command = commandSet[0];
isRelative = char.IsLower(command);
// http://www.w3.org/TR/SVG11/paths.html#PathDataGeneralInformation
......@@ -211,35 +211,45 @@ namespace Svg
commandStart = i;
if (!string.IsNullOrEmpty(command))
{
yield return command;
}
if (path.Length == i + 1)
{
yield return path[i].ToString();
}
}
else if (path.Length == i + 1)
{
command = path.Substring(commandStart, i - commandStart + 1).Trim();
if (!string.IsNullOrEmpty(command))
{
yield return command;
}
}
}
}
private static IEnumerable<float> ParseCoordinates(string coords)
{
// TODO: Handle "1-1" (new PointF(1, -1);
var parts = coords.Remove(0, 1).Replace("-", " -").Split(new[] { ',', ' ' },
var parts = coords.Remove(0, 1).Replace("-", " -").Split(new[] { ',', ' '},
StringSplitOptions.RemoveEmptyEntries);
for (var i = 0; i < parts.Length; i++)
yield return float.Parse(parts[i], NumberStyles.Float, CultureInfo.InvariantCulture);
{
yield return float.Parse(parts[i].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture);
}
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is string)
{
return Parse((string)value);
}
return base.ConvertFrom(context, culture, value);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment