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

Clean up string concatenations

Building a string with var = var .. "something" has miserable time
complexities. This commit cleans up a lot of that in scripts, focusing
on packing of data with bin.pack and concatenations within loops.
Additionally, a few instances were replaced with string.rep
This commit is contained in:
dmiller
2015-02-25 19:58:42 +00:00
parent ddb3905b20
commit 10dce0382c
26 changed files with 174 additions and 205 deletions

View File

@@ -177,11 +177,12 @@ end
local prepareRequest = function(fields, fieldvalues)
local filefield = 0
local req = ""
local req = {}
local value
for _, field in ipairs(fields) do
if field["type"] == "file" then
-- FIXME: What if there is more than one <input type="file">?
filefield = field
elseif field["type"] == "text" or field["type"] == "textarea" or field["type"] == "radio" or field["type"] == "checkbox" then
if fieldvalues[field["name"]] ~= nil then
@@ -189,11 +190,11 @@ local prepareRequest = function(fields, fieldvalues)
else
value = "SampleData0"
end
req = req .. '--AaB03x\nContent-Disposition: form-data; name="' .. field["name"] .. '";\n\n' .. value .. '\n'
req[#req+1] = ('--AaB03x\nContent-Disposition: form-data; name="%s";\n\n%s\n'):format(field["name"], value)
end
end
return req, filefield
return table.concat(req), filefield
end