1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-26 01:19:03 +00:00

o The command line in XML output (/nmaprun/@args attribute) now does

quoting of whitespace using double quotes and backslashes. This
  allows recovering the original command line array even when
  arguments contain whitespace. [David]
This commit is contained in:
david
2010-11-14 02:09:58 +00:00
parent 3c2b82100e
commit cec33e3aad
4 changed files with 46 additions and 2 deletions

View File

@@ -1190,6 +1190,41 @@ static void doscaninfo(const char *type, const char *proto,
xml_newline();
}
static std::string quote(const char *s) {
std::string result("");
const char *p;
bool space;
space = false;
for (p = s; *p != '\0'; p++) {
if (isspace(*p))
space = true;
if (*p == '"' || *p == '\\')
result += "\\";
result += *p;
}
if (space)
result = "\"" + result + "\"";
return result;
}
/* Return a std::string containing all n strings separated by whitespace, and
individually quoted if needed. */
std::string join_quoted(const char * const strings[], unsigned int n) {
std::string result("");
unsigned int i;
for (i = 0; i < n; i++) {
if (i > 0)
result += " ";
result += quote(strings[i]);
}
return result;
}
/* Similar to output_ports_to_machine_parseable_output, this function
outputs the XML version, which is scaninfo records of each scan
requested and the ports which it will scan for */