mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-11-16 18:28:21 +01:00
url.escape/url.unescape: Fix to return *only* the encoded/decoded string (thanks moodydeath)
This commit is contained in:
parent
908ee2cce1
commit
5c33ef9997
@ -26,9 +26,9 @@ _VERSION = "URL 1.0.1"
|
|||||||
-- escaped representation of string binary
|
-- escaped representation of string binary
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
function escape(s)
|
function escape(s)
|
||||||
return string.gsub(s, "([^A-Za-z0-9_])", function(c)
|
return (string.gsub(s, "([^A-Za-z0-9_])", function(c)
|
||||||
return string.format("%%%02x", string.byte(c))
|
return string.format("%%%02x", string.byte(c))
|
||||||
end)
|
end))
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
@ -69,9 +69,9 @@ end
|
|||||||
-- escaped representation of string binary
|
-- escaped representation of string binary
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
function unescape(s)
|
function unescape(s)
|
||||||
return string.gsub(s, "%%(%x%x)", function(hex)
|
return (string.gsub(s, "%%(%x%x)", function(hex)
|
||||||
return string.char(base.tonumber(hex, 16))
|
return string.char(base.tonumber(hex, 16))
|
||||||
end)
|
end))
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user