diff options
author | Kim Alvefur <zash@zash.se> | 2015-08-26 14:32:20 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2015-08-26 14:32:20 +0200 |
commit | ddf7f691b717e35f5dccf49fde62c1b6eec2d39c (patch) | |
tree | 0a3d49b641bcbb6491453a4a888b225d15270896 /util/hex.lua | |
parent | 0049dd0d5f58affe39b8acb0ae460bbd42ec4a8f (diff) | |
download | prosody-ddf7f691b717e35f5dccf49fde62c1b6eec2d39c.tar.gz prosody-ddf7f691b717e35f5dccf49fde62c1b6eec2d39c.zip |
util.hex: Normalize hex to lowercase and discard non-hex input
Diffstat (limited to 'util/hex.lua')
-rw-r--r-- | util/hex.lua | 3 |
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 } |