Fixed URL encoding to generate %0x instead of %x
[prosody.git] / net / http.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"