From 2d628779e8ad11c8026c43e8793764c2393c7472 Mon Sep 17 00:00:00 2001 From: chtenb Date: Sat, 20 Jan 2024 11:11:50 +0100 Subject: [PATCH] Add quotes around paths passed to graphviz (#73) --- Rubjerg.Graphviz.Test/Reproductions.cs | 10 ++++++++++ Rubjerg.Graphviz/GraphvizCommand.cs | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Rubjerg.Graphviz.Test/Reproductions.cs b/Rubjerg.Graphviz.Test/Reproductions.cs index c755eb5..eb1b355 100644 --- a/Rubjerg.Graphviz.Test/Reproductions.cs +++ b/Rubjerg.Graphviz.Test/Reproductions.cs @@ -1,4 +1,5 @@ using NUnit.Framework; +using System; using System.Globalization; using System.IO; using System.Linq; @@ -20,6 +21,15 @@ public void SetUp() _testDir = TestContext.CurrentContext.TestDirectory; } + [Test()] + public void ExportPathWithSpaces() + { + RootGraph root = RootGraph.CreateNew(GraphType.Directed, ""); + _ = root.GetOrAddNode("A"); + root.ToDotFile(TestContext.CurrentContext.TestDirectory + "/name with spaces.dot"); + root.ToSvgFile(TestContext.CurrentContext.TestDirectory + "/name with spaces.svg"); + } + [Test()] [TestCase("Times-Roman", 7, 0.01)] [TestCase("Times-Roman", 7, 0.5)] diff --git a/Rubjerg.Graphviz/GraphvizCommand.cs b/Rubjerg.Graphviz/GraphvizCommand.cs index 8cec2a4..3744f70 100644 --- a/Rubjerg.Graphviz/GraphvizCommand.cs +++ b/Rubjerg.Graphviz/GraphvizCommand.cs @@ -42,7 +42,7 @@ public static (byte[] stdout, string stderr) Exec(Graph input, string format = " string arguments = $"-T{format} -K{engine}"; if (outputPath != null) { - arguments = $"{arguments} -o{outputPath}"; + arguments = $"{arguments} -o\"{outputPath}\""; } string inputToStdin = input.ToDotString();