From 3372615e5bc22ed3d4f0f5990ce2e6e41dc06c4f Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 3 Sep 2023 10:13:02 -0400 Subject: [PATCH] Quote program name in completion output (fixes #1021) --- ChangeLog | 7 +++++++ libqpdf/QPDFArgParser.cc | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8362c189..30bf8ff6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2023-09-03 Jay Berkenbilt + * Put quotation marks around the command in completion output to + better handle spaces in paths. It is not a perfect fix (ideally, + full shell-compatible quoting should be used), but it handles more + cases than the old code and should handle all reasonable cases of + qpdf being in a directory with a space in its name, which is + common in Windows. Fixes #1021. + * Move check for random number device to runtime instead of compile time. Since, by default, the crypto provider provides random numbers, runtime determinination of a random number device diff --git a/libqpdf/QPDFArgParser.cc b/libqpdf/QPDFArgParser.cc index 3ebec29c..5377b2bc 100644 --- a/libqpdf/QPDFArgParser.cc +++ b/libqpdf/QPDFArgParser.cc @@ -193,7 +193,7 @@ QPDFArgParser::completionCommon(bool zsh) if (!zsh) { std::cout << " -o nospace"; } - std::cout << " -C " << progname << " " << m->whoami << std::endl; + std::cout << " -C \"" << progname << "\" " << m->whoami << std::endl; // Put output before error so calling from zsh works properly std::string path = progname; size_t slash = path.find('/');