aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-08-26 14:32:20 +0200
committerKim Alvefur <zash@zash.se>2015-08-26 14:32:20 +0200
commit4f034c3b7a9640e6e2174cbfde57a6ad435f2daa (patch)
tree0a3d49b641bcbb6491453a4a888b225d15270896
parent345a2e09f6a7fedd1037d7183548e60c6302719a (diff)
downloadprosody-4f034c3b7a9640e6e2174cbfde57a6ad435f2daa.tar.gz
prosody-4f034c3b7a9640e6e2174cbfde57a6ad435f2daa.zip
util.hex: Normalize hex to lowercase and discard non-hex input
-rw-r--r--util/hex.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/util/hex.lua b/util/hex.lua
index e41f4863..4cc28d33 100644
--- a/util/hex.lua
+++ b/util/hex.lua
@@ -1,6 +1,7 @@
local s_char = string.char;
local s_format = string.format;
local s_gsub = string.gsub;
+local s_lower = string.lower;
local char_to_hex = {};
local hex_to_char = {};
@@ -19,7 +20,7 @@ local function to(s)
end
local function from(s)
- return (s_gsub(s, "..", hex_to_char));
+ return (s_gsub(s_lower(s), "%X*(%x%x)%X*", hex_to_char));
end
return { to = to, from = from }