Comparison

util/datamanager.lua @ 7733:601c4d81603b

util.datamanager: Remove extraneous decoding of + to space, which we never never encode to
author Kim Alvefur <zash@zash.se>
date Sun, 20 Nov 2016 12:05:43 +0100
parent 7732:aba3dd84d9f0
child 7734:6a52415ed68a
comparison
equal deleted inserted replaced
7732:aba3dd84d9f0 7733:601c4d81603b
51 local encode, decode; 51 local encode, decode;
52 do 52 do
53 local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber(k, 16)); return t[k]; end }); 53 local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber(k, 16)); return t[k]; end });
54 54
55 decode = function (s) 55 decode = function (s)
56 return s and (s:gsub("+", " "):gsub("%%([a-fA-F0-9][a-fA-F0-9])", urlcodes)); 56 return s and (s:gsub("%%([a-fA-F0-9][a-fA-F0-9])", urlcodes));
57 end 57 end
58 58
59 encode = function (s) 59 encode = function (s)
60 return s and (s:gsub("%W", function (c) return format("%%%02x", c:byte()); end)); 60 return s and (s:gsub("%W", function (c) return format("%%%02x", c:byte()); end));
61 end 61 end