From 213e1a1ed6f75a541519e4030cc88ff851d6dd52 Mon Sep 17 00:00:00 2001 From: Daniel Naylor Date: Sun, 16 Jun 2024 19:04:08 +0100 Subject: [PATCH] Fixed bug relating to unsanitised pattern (#131) --- tex4ebook-exec_epub.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tex4ebook-exec_epub.lua b/tex4ebook-exec_epub.lua index de07c19..a2faf6b 100644 --- a/tex4ebook-exec_epub.lua +++ b/tex4ebook-exec_epub.lua @@ -150,11 +150,18 @@ function remove_empty_guide(content) return content:gsub("%s*","") end +local function startswith(str, prefix) + return str:sub(1, prefix:len()) == prefix +end + local function remove_builddir(filename) -- make4ht adds the build dir to all output files, -- but we don't want them there, because it is appended to the outdir local builddir = Make.params.builddir - return filename:gsub("^" .. builddir .. "/", "") + if startswith(filename, builddir .. "/") then + return filename:sub((builddir .. "/"):len() + 1) + end + return filename end