diff options
-rw-r--r-- | src/url.lua | 5 | ||||
-rw-r--r-- | test/urltest.lua | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/url.lua b/src/url.lua index 10a9d90..466d4fa 100644 --- a/src/url.lua +++ b/src/url.lua | |||
@@ -85,11 +85,11 @@ end | |||
85 | local function remove_dot_components(path) | 85 | local function remove_dot_components(path) |
86 | repeat | 86 | repeat |
87 | local was = path | 87 | local was = path |
88 | path = path:gsub('/%./', '/', 1) | 88 | path = path:gsub('//', '/'..0x00..'/', 1) |
89 | until path == was | 89 | until path == was |
90 | repeat | 90 | repeat |
91 | local was = path | 91 | local was = path |
92 | path = path:gsub('//%.%./([^/]+)', '/%1', 1) | 92 | path = path:gsub('/%./', '/', 1) |
93 | until path == was | 93 | until path == was |
94 | repeat | 94 | repeat |
95 | local was = path | 95 | local was = path |
@@ -99,6 +99,7 @@ local function remove_dot_components(path) | |||
99 | path = path:gsub('/%.%.$', '/') | 99 | path = path:gsub('/%.%.$', '/') |
100 | path = path:gsub('/%.$', '/') | 100 | path = path:gsub('/%.$', '/') |
101 | path = path:gsub('^/%.%./', '/') | 101 | path = path:gsub('^/%.%./', '/') |
102 | path = path:gsub(0x00, '') | ||
102 | return path | 103 | return path |
103 | end | 104 | end |
104 | 105 | ||
diff --git a/test/urltest.lua b/test/urltest.lua index 13deb10..ae8ba75 100644 --- a/test/urltest.lua +++ b/test/urltest.lua | |||
@@ -692,6 +692,10 @@ check_absolute_url("http://example.com/a/b/c/d/", "../../q", "http://example.com | |||
692 | check_absolute_url("http://example.com/a/b/c/d/", "../../../q", "http://example.com/a/q") | 692 | check_absolute_url("http://example.com/a/b/c/d/", "../../../q", "http://example.com/a/q") |
693 | check_absolute_url("http://example.com", ".badhost.com", "http://example.com/.badhost.com") | 693 | check_absolute_url("http://example.com", ".badhost.com", "http://example.com/.badhost.com") |
694 | check_absolute_url("http://example.com/a/b/c/d/", "..//../../../q", "http://example.com/a/q") | 694 | check_absolute_url("http://example.com/a/b/c/d/", "..//../../../q", "http://example.com/a/q") |
695 | check_absolute_url("http://example.com/a/b/c/d/", "..//a/../../../../q", "http://example.com/a/q") | ||
696 | check_absolute_url("http://example.com/a/b/c/d/", "..//a/..//../../../q", "http://example.com/a/b/q") | ||
697 | check_absolute_url("http://example.com/a/b/c/d/", "..//a/..///../../../../q", "http://example.com/a/b/q") | ||
698 | check_absolute_url("http://example.com/a/b/c/d/", "../x/a/../y/z/../../../../q", "http://example.com/a/b/q") | ||
695 | 699 | ||
696 | print("testing path parsing and composition") | 700 | print("testing path parsing and composition") |
697 | check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 }) | 701 | check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 }) |