From 38d936ec0ea05da9f85a5c582e5073e0d1b82209 Mon Sep 17 00:00:00 2001 From: "E. Westbrook" Date: Tue, 21 Aug 2018 11:27:42 -0600 Subject: [PATCH] url.lua:remove_dot_components(): empty path component double-dot corner case --- src/url.lua | 4 ++++ test/urltest.lua | 1 + 2 files changed, 5 insertions(+) diff --git a/src/url.lua b/src/url.lua index 243ee1c..10a9d90 100644 --- a/src/url.lua +++ b/src/url.lua @@ -87,6 +87,10 @@ local function remove_dot_components(path) local was = path path = path:gsub('/%./', '/', 1) until path == was + repeat + local was = path + path = path:gsub('//%.%./([^/]+)', '/%1', 1) + until path == was repeat local was = path path = path:gsub('[^/]+/%.%./([^/]+)', '%1', 1) diff --git a/test/urltest.lua b/test/urltest.lua index b6ee299..13deb10 100644 --- a/test/urltest.lua +++ b/test/urltest.lua @@ -691,6 +691,7 @@ check_absolute_url("http://example.com/a/b/c/d/", "../q", "http://example.com/a/ check_absolute_url("http://example.com/a/b/c/d/", "../../q", "http://example.com/a/b/q") check_absolute_url("http://example.com/a/b/c/d/", "../../../q", "http://example.com/a/q") check_absolute_url("http://example.com", ".badhost.com", "http://example.com/.badhost.com") +check_absolute_url("http://example.com/a/b/c/d/", "..//../../../q", "http://example.com/a/q") print("testing path parsing and composition") check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 })