Fixed URL encoding to generate %0x instead of %x
authorWaqas Hussain <waqas20@gmail.com>
Mon, 15 Dec 2008 22:46:17 +0000 (03:46 +0500)
committerWaqas Hussain <waqas20@gmail.com>
Mon, 15 Dec 2008 22:46:17 +0000 (03:46 +0500)
net/http.lua
prosody
tools/ejabberd2prosody.lua
util/datamanager.lua

index e8a981b8fb1d5db22b60c565f764bf6275075b64..a661bb522eaa307b21bae4703c219339c5a36eb1 100644 (file)
@@ -13,7 +13,7 @@ local tonumber, tostring, pairs = tonumber, tostring, pairs;
 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 --git a/prosody b/prosody
index 3b95663f59c1b14f9a77a6c0b058b1b129b8c558..98d15da2a6c3783c5b6f3b31dd26e38eb7101308 100755 (executable)
--- a/prosody
+++ b/prosody
@@ -115,7 +115,7 @@ function mkdir(path)
        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));
index 3c3ce9459fca2167b4175bc2788bee0dab3ab3b3..858d78bb54e6d5687b6eea97d6a61ee64fceb2cd 100755 (executable)
@@ -37,7 +37,7 @@ function mkdir(path)
        --print("mkdir",path);\r
        local x = io.popen("mkdir "..path.." 2>&1"):read("*a");\r
 end\r
-function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end\r
+function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%02x", c:byte()); end)); end\r
 function getpath(username, host, datastore, ext)\r
        ext = ext or "dat";\r
        if username then\r
index e229de1c7369b7afef326987f2ecf75cc021baf9..45da17ddfe6913562cbc32b00d1513df2a93cbad 100644 (file)
@@ -44,7 +44,7 @@ do
        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