mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-11-08 14:28:21 +01:00
url.lua:remove_dot_components(): avoid overconsuming dot segments
This commit is contained in:
parent
c570a32c21
commit
7ccea58776
@ -85,11 +85,11 @@ end
|
||||
local function remove_dot_components(path)
|
||||
repeat
|
||||
local was = path
|
||||
path = path:gsub('/%./', '/')
|
||||
path = path:gsub('/%./', '/', 1)
|
||||
until path == was
|
||||
repeat
|
||||
local was = path
|
||||
path = path:gsub('[^/]+/%.%./([^/]+)', '%1')
|
||||
path = path:gsub('[^/]+/%.%./([^/]+)', '%1', 1)
|
||||
until path == was
|
||||
path = path:gsub('[^/]+/%.%./*$', '')
|
||||
path = path:gsub('/%.%.$', '/')
|
||||
|
@ -654,6 +654,7 @@ check_absolute_url("http://a/b/c/d;p?q#f", "../g", "http://a/b/g")
|
||||
check_absolute_url("http://a/b/c/d;p?q#f", "../..", "http://a/")
|
||||
check_absolute_url("http://a/b/c/d;p?q#f", "../../", "http://a/")
|
||||
check_absolute_url("http://a/b/c/d;p?q#f", "../../g", "http://a/g")
|
||||
check_absolute_url("http://a/b/c/d;p?q#f", "../../../g", "http://a/g")
|
||||
check_absolute_url("http://a/b/c/d;p?q#f", "", "http://a/b/c/d;p?q#f")
|
||||
check_absolute_url("http://a/b/c/d;p?q#f", "/./g", "http://a/g")
|
||||
check_absolute_url("http://a/b/c/d;p?q#f", "/../g", "http://a/g")
|
||||
@ -686,6 +687,10 @@ check_absolute_url("http://velox.telemar.com.br", "/dashboard/index.html",
|
||||
"http://velox.telemar.com.br/dashboard/index.html")
|
||||
check_absolute_url("http://example.com/", "../.badhost.com/", "http://example.com/.badhost.com/")
|
||||
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/b/c/q")
|
||||
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/a/b/c/d/", "../../../../q", "http://example.com/q")
|
||||
|
||||
print("testing path parsing and composition")
|
||||
check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 })
|
||||
|
Loading…
Reference in New Issue
Block a user