projects
/
prosody.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
dcf4c0d
)
util.hex: Normalize hex to lowercase and discard non-hex input
author
Kim Alvefur
<zash@zash.se>
Wed, 26 Aug 2015 12:32:20 +0000
(14:32 +0200)
committer
Kim Alvefur
<zash@zash.se>
Wed, 26 Aug 2015 12:32:20 +0000
(14:32 +0200)
util/hex.lua
patch
|
blob
|
history
diff --git
a/util/hex.lua
b/util/hex.lua
index e41f48633de6faafbc4c94311c641a5fb1e14108..4cc28d33386f1f42dbe7d7cd1216e37757943e6c 100644
(file)
--- 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 }