summaryrefslogtreecommitdiffhomepage
path: root/libs/web/luasrc/http.lua
diff options
context:
space:
mode:
Diffstat (limited to 'libs/web/luasrc/http.lua')
-rw-r--r--libs/web/luasrc/http.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/web/luasrc/http.lua b/libs/web/luasrc/http.lua
index 68dad8f1ec..3bff28adde 100644
--- a/libs/web/luasrc/http.lua
+++ b/libs/web/luasrc/http.lua
@@ -43,4 +43,20 @@ function build_querystring(table)
end
return s
+end
+
+function urldecode(str)
+ str = str:gsub("+", " ")
+ str = str:gsub("%%(%x%x)",
+ function(h) return string.char(tonumber(h,16)) end)
+ str = str:gsub("\r\n", "\n")
+ return str
+end
+
+function urlencode(str)
+ str = str:gsub("\n", "\r\n")
+ str = str:gsub("([^%w ])",
+ function (c) return string.format ("%%%02X", string.byte(c)) end)
+ str = str:gsub(" ", "+")
+ return str
end \ No newline at end of file