From 7e6b8c8f267f41b77627b1c2bab0d9918efb9498 Mon Sep 17 00:00:00 2001
From: Matthew Wild <mwild1@gmail.com>
Date: Sat, 12 May 2012 02:50:38 +0100
Subject: net.http: Fix urlencode to not encode unreserved characters, so I can
 guiltlessly rant about people  who do.

---
 net/http.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'net')

diff --git a/net/http.lua b/net/http.lua
index 59f2c080..f2061e00 100644
--- a/net/http.lua
+++ b/net/http.lua
@@ -68,7 +68,7 @@ function listener.ondisconnect(conn, err)
 	requests[conn] = nil;
 end
 
-function urlencode(s) return s and (s:gsub("%W", function (c) return format("%%%02x", c:byte()); end)); end
+function urlencode(s) return s and (s:gsub("[^a-zA-Z0-9.~_-]", function (c) return format("%%%02x", c:byte()); end)); end
 function urldecode(s) return s and (s:gsub("%%(%x%x)", function (c) return char(tonumber(c,16)); end)); end
 
 local function _formencodepart(s)
-- 
cgit v1.2.3