From eb67213599670c9453dd32e37ed9f1bc7d809f96 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 20 Nov 2016 12:03:24 +0100 Subject: util.datamanager: Use the 'base' argument to tonumber() to indicate hexadecimal --- util/datamanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/datamanager.lua') diff --git a/util/datamanager.lua b/util/datamanager.lua index 2884b942..148605d9 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -50,7 +50,7 @@ local _ENV = nil; ---- utils ----- local encode, decode; do - 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] = char(tonumber(k, 16)); return t[k]; end }); decode = function (s) return s and (s:gsub("+", " "):gsub("%%([a-fA-F0-9][a-fA-F0-9])", urlcodes)); -- cgit v1.2.3 From b0adfce172e216dfe0a8767f598e80b0493a118c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 20 Nov 2016 12:05:43 +0100 Subject: util.datamanager: Remove extraneous decoding of + to space, which we never never encode to --- util/datamanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/datamanager.lua') diff --git a/util/datamanager.lua b/util/datamanager.lua index 148605d9..ddc71899 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -53,7 +53,7 @@ do local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber(k, 16)); return t[k]; end }); decode = function (s) - return s and (s:gsub("+", " "):gsub("%%([a-fA-F0-9][a-fA-F0-9])", urlcodes)); + return s and (s:gsub("%%([a-fA-F0-9][a-fA-F0-9])", urlcodes)); end encode = function (s) -- cgit v1.2.3 From 58a712e247dbaede24c3297260bae145e0ede16e Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 20 Nov 2016 12:06:36 +0100 Subject: util.datamanager: Shorter pattern --- util/datamanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/datamanager.lua') diff --git a/util/datamanager.lua b/util/datamanager.lua index ddc71899..585bb83d 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -53,7 +53,7 @@ do local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber(k, 16)); return t[k]; end }); decode = function (s) - return s and (s:gsub("%%([a-fA-F0-9][a-fA-F0-9])", urlcodes)); + return s and (s:gsub("%%(%x%x)", urlcodes)); end encode = function (s) -- cgit v1.2.3