Software /
code /
prosody
Changeset
5473:3db05041c278
Merge 0.9->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 15 Apr 2013 16:43:08 +0100 |
parents | 5469:fcdcc37ffec1 (current diff) 5472:7c631ef43b11 (diff) |
children | 5476:dc9485ac266b |
files | |
diffstat | 2 files changed, 14 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Fri Apr 12 00:45:46 2013 +0100 +++ b/Makefile Mon Apr 15 16:43:08 2013 +0100 @@ -38,7 +38,7 @@ install -m644 certs/* $(CONFIG)/certs install -m644 man/prosodyctl.man $(MAN)/man1/prosodyctl.1 test -e $(CONFIG)/prosody.cfg.lua || install -m644 prosody.cfg.lua.install $(CONFIG)/prosody.cfg.lua - test -e prosody.version && install prosody.version $(SOURCE)/prosody.version || true + test -e prosody.version && install -m644 prosody.version $(SOURCE)/prosody.version || true $(MAKE) install -C util-src clean:
--- a/util/http.lua Fri Apr 12 00:45:46 2013 +0100 +++ b/util/http.lua Mon Apr 15 16:43:08 2013 +0100 @@ -5,12 +5,14 @@ -- COPYING file in the source package for more information. -- -local http = {}; +local format, char = string.format, string.char; +local pairs, ipairs, tonumber = pairs, ipairs, tonumber; +local t_insert, t_concat = table.insert, table.concat; -function http.urlencode(s) +local function urlencode(s) return s and (s:gsub("[^a-zA-Z0-9.~_-]", function (c) return format("%%%02x", c:byte()); end)); end -function http.urldecode(s) +local function urldecode(s) return s and (s:gsub("%%(%x%x)", function (c) return char(tonumber(c,16)); end)); end @@ -24,7 +26,7 @@ end)); end -function http.formencode(form) +local function formencode(form) local result = {}; if form[1] then -- Array of ordered { name, value } for _, field in ipairs(form) do @@ -38,7 +40,7 @@ return t_concat(result, "&"); end -function http.formdecode(s) +local function formdecode(s) if not s:match("=") then return urldecode(s); end local r = {}; for k, v in s:gmatch("([^=&]*)=([^&]*)") do @@ -50,11 +52,13 @@ return r; end -function http.contains_token(field, token) +local function contains_token(field, token) field = ","..field:gsub("[ \t]", ""):lower()..","; return field:find(","..token:lower()..",", 1, true) ~= nil; end - - -return http; +return { + urlencode = urlencode, urldecode = urldecode; + formencode = formencode, formdecode = formdecode; + contains_token = contains_token; +};