about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-08-24T15·02+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-08-24T15·02+0000
commit3e8dccf6ab0918e89c4275ea9bf454d34e01534b (patch)
tree1b2bb7c10750e9abfe42aa4226b6e9cb38df501b /src
parent215ec2ddc6088be2291722a544c6ab5a1b00a5a1 (diff)
* Escape newlines in XML attributes to prevent them from being
  normalised away.

Diffstat (limited to 'src')
-rw-r--r--src/libutil/xml-writer.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libutil/xml-writer.cc b/src/libutil/xml-writer.cc
index cd37dff5608f..27235933e7fb 100644
--- a/src/libutil/xml-writer.cc
+++ b/src/libutil/xml-writer.cc
@@ -89,6 +89,9 @@ void XMLWriter::writeAttrs(const XMLAttrs & attrs)
             if (c == '"') output << "&quot;";
             else if (c == '<') output << "&lt;";
             else if (c == '&') output << "&amp;";
+            /* Escape newlines to prevent attribute normalisation (see
+               XML spec, section 3.3.3. */
+            else if (c == '\n') output << "&#xA;";
             else output << c;
         }
         output << "\"";