net.httpserver: Fix for urlencoding to always produce 2 digits

Mon, 04 May 2009 20:35:44 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Mon, 04 May 2009 20:35:44 +0100
changeset 1113
89ac8e9e1426
parent 1111
a1cf1d623695
child 1114
c463e30da312

net.httpserver: Fix for urlencoding to always produce 2 digits

net/httpserver.lua file | annotate | diff | comparison | revisions
--- a/net/httpserver.lua	Mon May 04 19:53:31 2009 +0100
+++ b/net/httpserver.lua	Mon May 04 20:35:44 2009 +0100
@@ -11,7 +11,7 @@
 local s_match, s_gmatch = string.match, string.gmatch;
 local tonumber, tostring, pairs = tonumber, tostring, pairs;
 
-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
 
 local log = require "util.logger".init("httpserver");
 

mercurial