Remove the single-string special case in stdnse.format_output.

This should be handled by the generic case, and I don't think it was
used anyway because the logic was wrong:

if(indent == nil and #data == 1 and type(data) == 'string' and not(data['name']) and not(data['warning'])) then
  return data[1]
end

This seems to be checking for a one-element table whose single element
is a string. But the test "#data == 1 and type(data) == 'string'" is
actually testing for a one-byte string. I think this is supposed to be
"type(data[1]) == 'string'", but anyway it should be handled by the
generic case.
This commit is contained in:
david 2010-12-30 21:08:15 +00:00
parent d9d47eb93d
commit 086b043cde

View file

@ -432,11 +432,6 @@ local function format_output_sub(status, data, indent)
return ""
end
-- Return a single line of output as-is (assuming it's top-level and a string)
if(indent == nil and #data == 1 and type(data) == 'string' and not(data['name']) and not(data['warning'])) then
return data[1]
end
-- Used to put 'ERROR: ' in front of all lines on error messages
local prefix = ""
-- Initialize the output string to blank (or, if we're at the top, add a newline)