From af72a45035a61752de4a0046debbd035c31399ee Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Fri, 20 Feb 2026 14:13:10 +0100 Subject: [PATCH] Fixed handling of paths in Pandoc exports (#674) --- .../Tools/PandocProcessBuilder.cs | 60 +++++++++++-------- .../wwwroot/changelog/v26.2.2.md | 1 + 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/app/MindWork AI Studio/Tools/PandocProcessBuilder.cs b/app/MindWork AI Studio/Tools/PandocProcessBuilder.cs index c2c404a7..6d95ad9f 100644 --- a/app/MindWork AI Studio/Tools/PandocProcessBuilder.cs +++ b/app/MindWork AI Studio/Tools/PandocProcessBuilder.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using System.Reflection; -using System.Text; using AIStudio.Tools.Metadata; using AIStudio.Tools.Services; @@ -74,36 +73,49 @@ public sealed class PandocProcessBuilder public async Task BuildAsync(RustService rustService) { - var sbArguments = new StringBuilder(); - - if (this.useStandaloneMode) - sbArguments.Append(" --standalone "); - - if(!string.IsNullOrWhiteSpace(this.providedInputFile)) - sbArguments.Append(this.providedInputFile); - - if(!string.IsNullOrWhiteSpace(this.providedInputFormat)) - sbArguments.Append($" -f {this.providedInputFormat}"); - - if(!string.IsNullOrWhiteSpace(this.providedOutputFormat)) - sbArguments.Append($" -t {this.providedOutputFormat}"); - - foreach (var additionalArgument in this.additionalArguments) - sbArguments.Append($" {additionalArgument}"); - - if(!string.IsNullOrWhiteSpace(this.providedOutputFile)) - sbArguments.Append($" -o {this.providedOutputFile}"); - var pandocExecutable = await PandocExecutablePath(rustService); - return new (new ProcessStartInfo + var startInfo = new ProcessStartInfo { FileName = pandocExecutable.Executable, - Arguments = sbArguments.ToString(), RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, CreateNoWindow = true - }, pandocExecutable.IsLocalInstallation); + }; + + // Use argument tokens instead of a single command string so paths with spaces + // or Unicode characters are passed to Pandoc unchanged on all platforms. + if (this.useStandaloneMode) + startInfo.ArgumentList.Add("--standalone"); + + if (!string.IsNullOrWhiteSpace(this.providedInputFile)) + startInfo.ArgumentList.Add(this.providedInputFile); + + if (!string.IsNullOrWhiteSpace(this.providedInputFormat)) + { + startInfo.ArgumentList.Add("-f"); + startInfo.ArgumentList.Add(this.providedInputFormat); + } + + if (!string.IsNullOrWhiteSpace(this.providedOutputFormat)) + { + startInfo.ArgumentList.Add("-t"); + startInfo.ArgumentList.Add(this.providedOutputFormat); + } + + foreach (var additionalArgument in this.additionalArguments) + { + if (!string.IsNullOrWhiteSpace(additionalArgument)) + startInfo.ArgumentList.Add(additionalArgument); + } + + if (!string.IsNullOrWhiteSpace(this.providedOutputFile)) + { + startInfo.ArgumentList.Add("-o"); + startInfo.ArgumentList.Add(this.providedOutputFile); + } + + return new(startInfo, pandocExecutable.IsLocalInstallation); } /// diff --git a/app/MindWork AI Studio/wwwroot/changelog/v26.2.2.md b/app/MindWork AI Studio/wwwroot/changelog/v26.2.2.md index 2865df75..713854bf 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v26.2.2.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v26.2.2.md @@ -17,6 +17,7 @@ - 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. - Fixed an issue where in some places "No profile" was displayed instead of the localized text. - 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. +- 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. - 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. - Upgraded to .NET 9.0.13 & Rust 1.93.1. - Upgraded dependencies. \ No newline at end of file