microsoft / automatic-graph-layout

A set of tools for graph layout and viewing
Other
1.34k stars 301 forks source link

Export to SVG incorrectly exports some characters. #352

Open wvdvegt opened 1 year ago

wvdvegt commented 1 year ago

When I export a graph containing certain characters , the SVG won't load/display in for example Microsoft Edge.

See https://github.com/microsoft/automatic-graph-layout/issues/351 for screenshots of the text used.

In the LabelTest the following characters are not exported properly:

FYI I was able to correct the '&' and '<' issue by supplying a nodeSanitizer to the SvgGraphWriter.Write() method.

Func<string, string> nodeSanitizer = s =>
{
return s
    .Replace("&", "&amp;")
    .Replace("<", "&lt;")
    .Replace(" ", "&#160;");
};
levnach commented 12 months ago

Should your change be a part of the default sanitizer? If so, please create a pull request.

wvdvegt commented 11 months ago

Not confortable enough with the code to make such changes & pull requests.

I was unware there was a default sanitizer at all. Did you mean the code in WriteLabelText()?