From c680f835c9bf3e357fbe6c655b721da68946c90a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 1 Aug 2005 13:39:19 +0000 Subject: [PATCH] * Escape ASCII characters < 32 to Unicode FFFD (REPLACEMENT CHARACTER) so that we don't produce un-wellformed XML. --- src/log2xml/log2xml.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/log2xml/log2xml.cc b/src/log2xml/log2xml.cc index a4955dc6e..c30fa5b02 100644 --- a/src/log2xml/log2xml.cc +++ b/src/log2xml/log2xml.cc @@ -117,10 +117,11 @@ void Decoder::finishLine() if (priority != 1) cout << " priority='" << priority << "'"; cout << ">"; - for (int i = 0; i < line.size(); i++) { + for (unsigned int i = 0; i < line.size(); i++) { if (line[i] == '<') cout << "<"; else if (line[i] == '&') cout << "&"; + else if (line[i] < 32 && line[i] != 9) cout << "�"; else if (i + sz + 33 < line.size() && string(line, i, sz) == storeDir && line[i + sz + 32] == '-')