mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 12:28:21 +01:00
Merge pull request #210 from Lord-Helmchen/patch-1
make protect_segment in url.lua rfc compliant
This commit is contained in:
commit
ff1a447b4d
@ -49,7 +49,7 @@ local function make_set(t)
|
|||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
-- these are allowed withing a path segment, along with alphanum
|
-- these are allowed within a path segment, along with alphanum
|
||||||
-- other characters must be escaped
|
-- other characters must be escaped
|
||||||
local segment_set = make_set {
|
local segment_set = make_set {
|
||||||
"-", "_", ".", "!", "~", "*", "'", "(",
|
"-", "_", ".", "!", "~", "*", "'", "(",
|
||||||
@ -59,7 +59,7 @@ local segment_set = make_set {
|
|||||||
local function protect_segment(s)
|
local function protect_segment(s)
|
||||||
return string.gsub(s, "([^A-Za-z0-9_])", function (c)
|
return string.gsub(s, "([^A-Za-z0-9_])", function (c)
|
||||||
if segment_set[c] then return c
|
if segment_set[c] then return c
|
||||||
else return string.format("%%%02x", string.byte(c)) end
|
else return string.format("%%%02X", string.byte(c)) end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user