# HG changeset patch
# User Matthew Wild <mwild1@gmail.com>
# Date 1240428705 -3600
# Node ID ececc4162d589cfc9dc3c17a6ee9c4805f47f4d3
# Parent  bb21eb3cd36443fb3485201acc939b853c78c679
net.httpserver: Fix potential nil access

diff -r bb21eb3cd364 -r ececc4162d58 net/httpserver.lua
--- a/net/httpserver.lua	Mon May 04 19:38:21 2009 +0100
+++ b/net/httpserver.lua	Wed Apr 22 20:31:45 2009 +0100
@@ -8,10 +8,10 @@
 local listener;
 
 local t_insert, t_concat = table.insert, table.concat;
-local s_match, s_gmatch = string.match, string.gmatch;
+local s_match, s_gmatch, s_char = string.match, string.gmatch;
 local tonumber, tostring, pairs = tonumber, tostring, pairs;
 
-local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber("0x"..k)); return t[k]; end });
+local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = s_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 log = require "util.logger".init("httpserver");