Changeset

4865:9171dc2357e0

net.http: Fix urlencode to not encode unreserved characters, so I can guiltlessly rant about people who do.
author Matthew Wild <mwild1@gmail.com>
date Sat, 12 May 2012 02:50:38 +0100
parents 4864:b98154bbe0e0
children 4866:d54999db3aa1
files net/http.lua
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/net/http.lua	Sat May 12 01:47:53 2012 +0100
+++ b/net/http.lua	Sat May 12 02:50:38 2012 +0100
@@ -68,7 +68,7 @@
 	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)