diff options
author | Steven Barth <steven@midlink.org> | 2008-06-07 06:44:27 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-06-07 06:44:27 +0000 |
commit | f8925eefa3b487c4573da63f99f6f19292ae4297 (patch) | |
tree | 0911cb7c0c7d5cad806b0a3670ee2602b68e39ae /libs/web/luasrc/http.lua | |
parent | cdd871d8347b82b4fbbcf95f8b79641e5d18d660 (diff) |
* libs/web: Fixed Luci template cache
* libs/web: Added luci.http.urlencode, luci.http.urldecode
* Minor enhancements
Diffstat (limited to 'libs/web/luasrc/http.lua')
-rw-r--r-- | libs/web/luasrc/http.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/web/luasrc/http.lua b/libs/web/luasrc/http.lua index 68dad8f1e..3bff28add 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 |