From 086b043cde5204126fe59749a689fbdb5490c806 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 30 Dec 2010 21:08:15 +0000 Subject: [PATCH] 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. --- nselib/stdnse.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/nselib/stdnse.lua b/nselib/stdnse.lua index 1b05ced5b..9d9ab36df 100644 --- a/nselib/stdnse.lua +++ b/nselib/stdnse.lua @@ -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)