Skip to content

Commit 40a65e3

Browse files
committed
escape build dir in the output file name pattern
1 parent 2847d39 commit 40a65e3

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
- 2026/05/11
4+
5+
- added new `mkutils` function, `escape_pattern`
6+
- use `escape_pattern` to sanitize output file names
7+
https://tex.stackexchange.com/q/762690/2891
8+
39
- 2026/05/10
410

511
- set anchor id in lists to the `<li>` element in the `itemparagraphs` DOM filter.

make4ht

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ make:match(".*",function(filename,par)
132132
return true
133133
end
134134
log:info("outdir: "..outdir)
135-
local outfilename = filename:gsub("^" .. (par.builddir or ""), "")
135+
local outfilename = filename:gsub("^" .. mkutils.escape_pattern(par.builddir or ""), "")
136136
outfilename = outdir .. outfilename
137137
mkutils.copy(filename,outfilename)
138138
return true

mkutils.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,11 @@ local function run(untrusted_code, env)
320320
return pcall(untrusted_function)
321321
end
322322

323+
function escape_pattern(str)
324+
-- escape all magic characters in the string, so it can be used as a literal pattern
325+
return (str:gsub("([%(%)%.%%%+%-%*%?%[%]%^%$])", "%%%1"))
326+
end
327+
323328
local main_settings = {}
324329
main_settings.fonts = {}
325330
-- use global environment in the build file

0 commit comments

Comments
 (0)