From 21992c9c7c8006cf2160db67ba1b9c1289666227 Mon Sep 17 00:00:00 2001 From: vinamra Date: Mon, 10 Jul 2017 11:19:55 +0000 Subject: [PATCH] Adds /./ to normalize_path. Closes #920 --- scripts/http-sitemap-generator.nse | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/http-sitemap-generator.nse b/scripts/http-sitemap-generator.nse index d8d3d180c..bb2f8f5a3 100644 --- a/scripts/http-sitemap-generator.nse +++ b/scripts/http-sitemap-generator.nse @@ -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