# HG changeset patch # User Waqas Hussain # Date 1229381177 -18000 # Node ID 3712d36b6d256207e348973896c2f0ec481dcd82 # Parent cd2cab5400fc467c40a96b39f71fd58fee55c152 Fixed URL encoding to generate %0x instead of %x diff -r cd2cab5400fc -r 3712d36b6d25 net/http.lua --- a/net/http.lua Sat Dec 13 17:43:52 2008 +0000 +++ b/net/http.lua Tue Dec 16 03:46:17 2008 +0500 @@ -13,7 +13,7 @@ local print = function () end local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber("0x"..k)); return t[k]; end }); -local urlencode = function (s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end +local urlencode = function (s) return s and (s:gsub("%W", function (c) return string.format("%%%02x", c:byte()); end)); end module "http" diff -r cd2cab5400fc -r 3712d36b6d25 prosody --- a/prosody Sat Dec 13 17:43:52 2008 +0000 +++ b/prosody Tue Dec 16 03:46:17 2008 +0500 @@ -115,7 +115,7 @@ path = path:gsub("/", path_separator); local x = io.popen("mkdir \""..path.."\" 2>&1"):read("*a"); end -function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end +function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%02x", c:byte()); end)); end function mkdirs(host) if not _mkdir[host] then local host_dir = string.format("%s/%s", data_path, encode(host)); diff -r cd2cab5400fc -r 3712d36b6d25 tools/ejabberd2prosody.lua --- a/tools/ejabberd2prosody.lua Sat Dec 13 17:43:52 2008 +0000 +++ b/tools/ejabberd2prosody.lua Tue Dec 16 03:46:17 2008 +0500 @@ -37,7 +37,7 @@ --print("mkdir",path); local x = io.popen("mkdir "..path.." 2>&1"):read("*a"); end -function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end +function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%02x", c:byte()); end)); end function getpath(username, host, datastore, ext) ext = ext or "dat"; if username then diff -r cd2cab5400fc -r 3712d36b6d25 util/datamanager.lua --- a/util/datamanager.lua Sat Dec 13 17:43:52 2008 +0000 +++ b/util/datamanager.lua Tue Dec 16 03:46:17 2008 +0500 @@ -44,7 +44,7 @@ end encode = function (s) - return s and (s:gsub("%W", function (c) return format("%%%x", c:byte()); end)); + return s and (s:gsub("%W", function (c) return format("%%%02x", c:byte()); end)); end end