[latex3-commits] [git/LaTeX3-latex3-l3build] spaces: More escaping (182513f)

Marcel Fabian Krüger tex at 2krueger.de
Tue Apr 19 23:03:08 CEST 2022


Repository : https://github.com/latex3/l3build
On branch  : spaces
Link       : https://github.com/latex3/l3build/commit/182513fb67aced7fb46a22252cf69a0c919bbf70

>---------------------------------------------------------------

commit 182513fb67aced7fb46a22252cf69a0c919bbf70
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Tue Apr 19 23:02:42 2022 +0200

    More escaping


>---------------------------------------------------------------

182513fb67aced7fb46a22252cf69a0c919bbf70
 l3build-aux.lua            |  8 ++++----
 l3build-check.lua          | 11 ++++++-----
 l3build-file-functions.lua |  4 ++--
 l3build-typesetting.lua    | 26 +++++++++++++-------------
 4 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/l3build-aux.lua b/l3build-aux.lua
index 2f6902a..070a909 100644
--- a/l3build-aux.lua
+++ b/l3build-aux.lua
@@ -121,12 +121,12 @@ function call(modules, target, opts)
           end
         end
       end
-      cli_opts = cli_opts .. " --" .. k .. value
+      cli_opts = cli_opts .. " " .. escape_arg("--" .. k .. value)
     end
   end
   if opts.names then
     for _, name in pairs(opts.names) do
-      cli_opts = cli_opts .. " " .. name
+      cli_opts = cli_opts .. " " .. escape_arg(name)
     end
   end
   local script_name = get_script_name()
@@ -140,7 +140,7 @@ function call(modules, target, opts)
     print("Running l3build with target \"" .. target .. "\"" .. text )
     local error_level = run(
       module,
-      "texlua " .. script_name .. " " .. target .. cli_opts
+      "texlua " .. escape_arg(script_name) .. " " .. escape_arg(target) .. cli_opts
     )
     if error_level ~= 0 then
       return error_level
@@ -159,7 +159,7 @@ function dep_install(deps)
   local error_level
   for _, dep in ipairs(deps) do
     print("Installing dependency: " .. dep)
-    error_level = run(dep, "texlua " .. get_script_name() .. " unpack -q")
+    error_level = run(dep, "texlua " .. escape_arg(get_script_name()) .. " unpack -q")
     if error_level ~= 0 then
       return error_level
     end
diff --git a/l3build-check.lua b/l3build-check.lua
index 726f7e6..346f5e9 100644
--- a/l3build-check.lua
+++ b/l3build-check.lua
@@ -741,7 +741,7 @@ function runtest(name, engine, hide, ext, test_type, breakout)
       binary    = engine_info.binary  or binary
       format    = engine_info.format  or format
       checkopts = engine_info.options or checkopts
-      tokens    = engine_info.tokens and (' "' .. engine_info.tokens .. '" ')
+      tokens    = engine_info.tokens and (' ' .. escape_arg(engine_info.tokens))
                     or tokens
     end
   end
@@ -758,10 +758,10 @@ function runtest(name, engine, hide, ext, test_type, breakout)
     return " -jobname=" .. name .. tokens .. ' "\\input ' .. file .. '" '
   end
   if match(checkformat,"^context$") then
-    function setup(file) return tokens .. ' "' .. file .. '" '  end
+    function setup(file) return tokens .. ' ' .. escape_arg(file) .. ' '  end
   end
   if match(binary,"make4ht") then
-    function setup(file) return tokens .. ' "' .. file .. '" '  end
+    function setup(file) return tokens .. ' "' .. escape_arg(file) .. '" '  end
     format = ""
     checkopts = ""
   end
@@ -783,14 +783,15 @@ function runtest(name, engine, hide, ext, test_type, breakout)
   rmfile(testdir,name .. logext)
   local errlevels = {}
   for i = 1, checkruns do
+    -- FIXME
     errlevels[i] = run(
       testdir,
       -- No use of localdir here as the files get copied to testdir:
       -- avoids any paths in the logs
-      os_setenv .. " TEXINPUTS=." .. localtexmf()
+      os_setenv .. " TEXINPUTS=." .. escape_arg(localtexmf())
         .. (checksearch and os_pathsep or "")
         .. os_concat ..
-      os_setenv .. " LUAINPUTS=." .. localtexmf()
+      os_setenv .. " LUAINPUTS=." .. escape_arg(localtexmf())
         .. (checksearch and os_pathsep or "")
         .. os_concat ..
       -- Avoid spurious output from (u)pTeX
diff --git a/l3build-file-functions.lua b/l3build-file-functions.lua
index 2b2cf24..acec2b0 100644
--- a/l3build-file-functions.lua
+++ b/l3build-file-functions.lua
@@ -183,7 +183,7 @@ function abspath(path)
 end
 
 -- TODO: Fix the cross platform problem
-function escapepath(path)
+function escape_arg(path)
   if os_type == "windows" then
     local path,count = gsub(path,'"','')
     if count % 2 ~= 0 then
@@ -203,7 +203,7 @@ function escapepath(path)
 end
 
 function normalize_and_escape(path)
-  return escapepath(normalize_path(path))
+  return escape_arg(normalize_path(path))
 end
 
 -- For cleaning out a directory, which also ensures that it exists
diff --git a/l3build-typesetting.lua b/l3build-typesetting.lua
index c173b25..917f6f3 100644
--- a/l3build-typesetting.lua
+++ b/l3build-typesetting.lua
@@ -39,10 +39,10 @@ function dvitopdf(name, dir, engine, hide)
   run(
     dir,
     set_epoch_cmd(epoch, forcecheckepoch) ..
-    "dvips " .. name .. dviext
+    "dvips " .. normalize_and_escape(name .. dviext)
       .. (hide and (" > " .. os_null) or "")
       .. os_concat ..
-    "ps2pdf " .. ps2pdfopt .. name .. psext
+    "ps2pdf " .. ps2pdfopt .. normalize_and_escape(name .. psext)
       .. (hide and (" > " .. os_null) or "")
   )
 end
@@ -70,7 +70,7 @@ end
 function biber(name,dir)
   if fileexists(dir .. "/" .. name .. ".bcf") then
     return
-      runcmd(biberexe .. " " .. biberopts .. " " .. name,dir,{"BIBINPUTS"})
+      runcmd(biberexe .. " " .. biberopts .. " " .. normalize_and_escape(name),dir,{"BIBINPUTS"})
   end
   return 0
 end
@@ -82,18 +82,18 @@ function bibtex(name,dir)
     -- look inside it for a \citation line
     local grep
     if os_type == "windows" then
-      grep = "\\\\"
+      grep = [[\\]]
     else
-     grep = "\\\\\\\\"
+     grep = [[\\\\]]
     end
     if run(dir,
-        os_grepexe .. " \"^" .. grep .. "citation{\" " .. name .. ".aux > "
-          .. os_null
+        os_grepexe .. " \"^" .. grep .. "citation{\" " .. normalize_and_escape(name .. ".aux")
+          .. " > " .. os_null
       ) + run(dir,
-        os_grepexe .. " \"^" .. grep .. "bibdata{\" " .. name .. ".aux > "
-          .. os_null
+        os_grepexe .. " \"^" .. grep .. "bibdata{\" " .. normalize_and_escape(name .. ".aux")
+          .. " > " .. os_null
       ) == 0 then
-      return runcmd(bibtexexe .. " " .. bibtexopts .. " " .. name,dir,
+      return runcmd(bibtexexe .. " " .. bibtexopts .. " " .. normalize_and_escape(name),dir,
         {"BIBINPUTS","BSTINPUTS"})
     end
   end
@@ -105,9 +105,9 @@ function makeindex(name,dir,inext,outext,logext,style)
   if fileexists(dir .. "/" .. name .. inext) then
     if style == "" then style = nil end
     return runcmd(makeindexexe .. " " .. makeindexopts
-      .. " -o " .. name .. outext
-      .. (style and (" -s " .. style) or "")
-      .. " -t " .. name .. logext .. " "  .. name .. inext,
+      .. " -o " .. normalize_and_escape(name .. outext)
+      .. (style and (" -s " .. escape_arg(style)) or "")
+      .. " -t " .. normalize_and_escape(name .. logext) .. " "  .. normalize_and_escape(name .. inext),
       dir,
       {"INDEXSTYLE"})
   end





More information about the latex3-commits mailing list.