commit a8c0b2f707a4ef23dbd5c03b422b3a2536d398aa
Author: Pavel Sanda <[email protected]>
Date: Sat May 23 19:58:10 2026 +0200
Route kpsewhich invocation through argv form
Use startscriptArgv() instead of fragile quoting hotfixes.
The "--" separator stays: kpsewhich would otherwise read '-' as an option
flag.
Tier 01 DiD / argv 02: argv-form kpsewhich; re-closes 00a structurally,
removes one runCommand caller
https://www.mail-archive.com/[email protected]/msg226746.html
Assisted-by: Claude Opus 4.7
---
src/support/filetools.cpp | 27 +++++++++------------------
1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp
index f92d5a1843..7e11a18290 100644
--- a/src/support/filetools.cpp
+++ b/src/support/filetools.cpp
@@ -1259,25 +1259,16 @@ FileName const findtexfile(string const & fil, string
const & /*format*/,
if (fil.empty())
return FileName();
- // Wrap fil in the shell's quoting form that disables the relevant
- // metacharacter set.
-#ifdef _WIN32
- // Reject '"' in filename, can't be backslashed & forbidden by NTFS
anyway
- if (fil.find('"') != string::npos)
- return FileName();
- // disable metacharacters
- string const kpsecmd = "kpsewhich -- \"" + fil + "\"";
-#else
- // disable metacharacters & escape existing '
- string const kpsecmd = "kpsewhich -- '" + subst(fil, "'", "'\\''") +
"'";
-#endif
-
- cmd_ret const c = runCommand(kpsecmd);
+ // fil is user-controlled (e.g. the bibfiles parameter of a
CommandInset bibtex) -
+ // avoid shell & arguments parsing. Keep "--" to delimit kpsewhich
options.
+ Systemcall one;
+ string kpse_out;
+ int const ret = one.startscriptArgv("kpsewhich", { "--", fil },
&kpse_out);
- LYXERR(Debug::OUTFILE, "kpse status = " << c.valid << '\n'
- << "kpse result = `" <<
rtrim(c.result, "\n\r") << '\'');
- if (c.valid)
- return FileName(rtrim(to_utf8(from_filesystem8bit(c.result)),
"\n\r"));
+ LYXERR(Debug::OUTFILE, "kpse status = " << ret << '\n'
+ << "kpse result = `" <<
rtrim(kpse_out, "\n\r") << '\'');
+ if (ret == Systemcall::OK)
+ return FileName(rtrim(to_utf8(from_filesystem8bit(kpse_out)),
"\n\r"));
else
return FileName();
}
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs