1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Fix stdnse.tohex not adding separators. Fixes #2531

This commit is contained in:
dmiller
2022-09-30 20:03:37 +00:00
parent 2b4b822557
commit 914cd2b272

View File

@@ -314,14 +314,11 @@ function tohex( s, options )
-- format hex if we got a separator
if separator then
local group = options.group or 2
local left = #hex
gsub(hex, ".", function(h)
left = left - 1
if left % group == 0 and left > 0 then
return h .. separator
end
return h
end)
local subs = 0
local pat = "(%x)(" .. rep("[^:]", group) .. ")%f[\0:]"
repeat
hex, subs = gsub(hex, pat, "%1:%2")
until subs == 0
end
return hex