diff options
| author | E. Westbrook <github@westbrook.io> | 2018-08-21 12:02:25 -0600 |
|---|---|---|
| committer | E. Westbrook <github@westbrook.io> | 2018-08-21 12:17:12 -0600 |
| commit | ca5398be098b571912dcbd93c83ab78151814f99 (patch) | |
| tree | 6355345432154e3ce550f7f133742653a5ed13c6 /src | |
| parent | 38d936ec0ea05da9f85a5c582e5073e0d1b82209 (diff) | |
| download | luasocket-ca5398be098b571912dcbd93c83ab78151814f99.tar.gz luasocket-ca5398be098b571912dcbd93c83ab78151814f99.tar.bz2 luasocket-ca5398be098b571912dcbd93c83ab78151814f99.zip | |
url.lua:remove_dot_components(): use temporary NUL marker to reduce empty-segment special-case code
Diffstat (limited to 'src')
| -rw-r--r-- | src/url.lua | 5 |
1 files changed, 3 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 | ||
