mirror of
https://github.com/nmap/nmap.git
synced 2025-12-26 09:29:01 +00:00
Use string.gsub instead of looped concat to modify strings
This commit is contained in:
@@ -101,13 +101,12 @@ function name_decode(encoded_name)
|
||||
|
||||
stdnse.debug3("Decoding name '%s'", encoded_name)
|
||||
|
||||
for i = 2, len + 1, 2 do
|
||||
local ch = 0
|
||||
ch = bit.bor(ch, bit.lshift(string.byte(encoded_name, i) - 0x41, 4))
|
||||
ch = bit.bor(ch, bit.lshift(string.byte(encoded_name, i + 1) - 0x41, 0))
|
||||
|
||||
name = name .. string.char(ch)
|
||||
end
|
||||
name = name:gsub("(.)(.)", function (a, b)
|
||||
local ch = 0
|
||||
ch = bit.bor(ch, bit.lshift(string.byte(a) - 0x41, 4))
|
||||
ch = bit.bor(ch, bit.lshift(string.byte(b) - 0x41, 0))
|
||||
return string.char(ch)
|
||||
end)
|
||||
|
||||
-- Decode the scope
|
||||
local pos = 34
|
||||
|
||||
Reference in New Issue
Block a user