1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Adds /./ to normalize_path. Closes #920

This commit is contained in:
vinamra
2017-07-10 11:19:55 +00:00
parent 30f0fab5bc
commit 21992c9c7c

View File

@@ -108,10 +108,12 @@ local function get_file_extension(f)
return string.match(f, ".-/.-%.([^/%.]*)$") or "Other"
end
-- removes /../ from paths; for example
-- removes /../ and /./ from paths; for example
-- normalize_path("/a/v/../../da/as/d/a/a/aa/../") -> "/da/as/d/a/a/"
local function normalize_path(p)
local n=0
p = p:gsub("/%.%f[/]", "")
p = p:gsub("/%.$", "/")
repeat
p, n = string.gsub(p, "/[^/]-/%.%.", "")
until n==0