url.lua:remove_dot_components(): avoid overconsuming dot segments

This commit is contained in:
E. Westbrook 2018-08-21 09:59:45 -06:00
parent c570a32c21
commit 7ccea58776
2 changed files with 7 additions and 2 deletions

View file

@ -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('/%.%.$', '/')