fix: file time column escapes ()[] chars in parser (#603)

This commit is contained in:
Steven Arcangeli 2025-03-30 15:14:11 -07:00
parent ab887d926c
commit ba1f50a9a8

View file

@ -183,7 +183,17 @@ for _, time_key in ipairs({ "ctime", "mtime", "atime", "birthtime" }) do
-- Replace placeholders with a pattern that matches non-space characters (e.g. %H -> %S+)
-- and whitespace with a pattern that matches any amount of whitespace
-- e.g. "%b %d %Y" -> "%S+%s+%S+%s+%S+"
pattern = fmt:gsub("%%.", "%%S+"):gsub("%s+", "%%s+")
pattern = fmt
:gsub("%%.", "%%S+")
:gsub("%s+", "%%s+")
-- escape `()[]` because those are special characters in Lua patterns
:gsub(
"%(",
"%%("
)
:gsub("%)", "%%)")
:gsub("%[", "%%[")
:gsub("%]", "%%]")
else
pattern = "%S+%s+%d+%s+%d%d:?%d%d"
end