Software /
code /
prosody
Changeset
6802:442019e955dc
util.hex: Normalize hex to lowercase and discard non-hex input
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 26 Aug 2015 14:32:20 +0200 |
parents | 6798:8b4c8e957211 |
children | 6803:7ed87299dbf9 |
files | util/hex.lua |
diffstat | 1 files changed, 2 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/util/hex.lua Wed Aug 26 13:17:10 2015 +0200 +++ b/util/hex.lua Wed Aug 26 14:32:20 2015 +0200 @@ -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 @@ 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 }