about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-08-01T13·39+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-08-01T13·39+0000
commitc680f835c9bf3e357fbe6c655b721da68946c90a (patch)
tree42648a874941f2d121e3a76663b4174f425e33b8
parentf450c8ea2f0917f3a8df77d8c849eed713f96cbd (diff)
* Escape ASCII characters < 32 to Unicode FFFD (REPLACEMENT CHARACTER)
  so that we don't produce un-wellformed XML.

-rw-r--r--src/log2xml/log2xml.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/log2xml/log2xml.cc b/src/log2xml/log2xml.cc
index a4955dc6e82d..c30fa5b02667 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 << "&lt;";
         else if (line[i] == '&') cout << "&amp;";
+        else if (line[i] < 32 && line[i] != 9) cout << "&#xfffd;";
         else if (i + sz + 33 < line.size() &&
             string(line, i, sz) == storeDir &&
             line[i + sz + 32] == '-')