1
0
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:
dmiller
2015-02-27 14:55:29 +00:00
parent d16772a8a8
commit e275a96c72
5 changed files with 23 additions and 42 deletions

View File

@@ -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