Skip to content

Commit af72a45

Browse files
Fixed handling of paths in Pandoc exports (#674)
1 parent 6f76c84 commit af72a45

2 files changed

Lines changed: 37 additions & 24 deletions

File tree

app/MindWork AI Studio/Tools/PandocProcessBuilder.cs

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Diagnostics;
22
using System.Reflection;
3-
using System.Text;
43

54
using AIStudio.Tools.Metadata;
65
using AIStudio.Tools.Services;
@@ -74,36 +73,49 @@ public PandocProcessBuilder UseStandaloneMode()
7473

7574
public async Task<PandocPreparedProcess> BuildAsync(RustService rustService)
7675
{
77-
var sbArguments = new StringBuilder();
78-
79-
if (this.useStandaloneMode)
80-
sbArguments.Append(" --standalone ");
81-
82-
if(!string.IsNullOrWhiteSpace(this.providedInputFile))
83-
sbArguments.Append(this.providedInputFile);
84-
85-
if(!string.IsNullOrWhiteSpace(this.providedInputFormat))
86-
sbArguments.Append($" -f {this.providedInputFormat}");
87-
88-
if(!string.IsNullOrWhiteSpace(this.providedOutputFormat))
89-
sbArguments.Append($" -t {this.providedOutputFormat}");
90-
91-
foreach (var additionalArgument in this.additionalArguments)
92-
sbArguments.Append($" {additionalArgument}");
93-
94-
if(!string.IsNullOrWhiteSpace(this.providedOutputFile))
95-
sbArguments.Append($" -o {this.providedOutputFile}");
96-
9776
var pandocExecutable = await PandocExecutablePath(rustService);
98-
return new (new ProcessStartInfo
77+
var startInfo = new ProcessStartInfo
9978
{
10079
FileName = pandocExecutable.Executable,
101-
Arguments = sbArguments.ToString(),
10280
RedirectStandardOutput = true,
10381
RedirectStandardError = true,
10482
UseShellExecute = false,
10583
CreateNoWindow = true
106-
}, pandocExecutable.IsLocalInstallation);
84+
};
85+
86+
// Use argument tokens instead of a single command string so paths with spaces
87+
// or Unicode characters are passed to Pandoc unchanged on all platforms.
88+
if (this.useStandaloneMode)
89+
startInfo.ArgumentList.Add("--standalone");
90+
91+
if (!string.IsNullOrWhiteSpace(this.providedInputFile))
92+
startInfo.ArgumentList.Add(this.providedInputFile);
93+
94+
if (!string.IsNullOrWhiteSpace(this.providedInputFormat))
95+
{
96+
startInfo.ArgumentList.Add("-f");
97+
startInfo.ArgumentList.Add(this.providedInputFormat);
98+
}
99+
100+
if (!string.IsNullOrWhiteSpace(this.providedOutputFormat))
101+
{
102+
startInfo.ArgumentList.Add("-t");
103+
startInfo.ArgumentList.Add(this.providedOutputFormat);
104+
}
105+
106+
foreach (var additionalArgument in this.additionalArguments)
107+
{
108+
if (!string.IsNullOrWhiteSpace(additionalArgument))
109+
startInfo.ArgumentList.Add(additionalArgument);
110+
}
111+
112+
if (!string.IsNullOrWhiteSpace(this.providedOutputFile))
113+
{
114+
startInfo.ArgumentList.Add("-o");
115+
startInfo.ArgumentList.Add(this.providedOutputFile);
116+
}
117+
118+
return new(startInfo, pandocExecutable.IsLocalInstallation);
107119
}
108120

109121
/// <summary>

app/MindWork AI Studio/wwwroot/changelog/v26.2.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- Fixed an issue where manually saving chats in workspace manual-storage mode could appear unreliable during response streaming. The save button is now disabled while streaming to prevent partial saves.
1818
- Fixed an issue where in some places "No profile" was displayed instead of the localized text.
1919
- Fixed a bug in the Responses API of our OpenAI provider implementation where streamed whitespace chunks were discarded. We thank Oliver Kunc `OliverKunc` for his first contribution in resolving this issue. We appreciate your help, Oliver.
20+
- Fixed a bug in the Microsoft Word export via Pandoc where target paths containing spaces or Unicode characters could be split into invalid command arguments, resulting in export failures.
2021
- Fixed the Google Gemini model API. Switched to the default OpenAI-compatible API to retrieve the model list after Google changed the previous API, which stopped working.
2122
- Upgraded to .NET 9.0.13 & Rust 1.93.1.
2223
- Upgraded dependencies.

0 commit comments

Comments
 (0)