Issue 1472827: xml.sax.saxutils.XMLGenerator mangles \r\n\t in attributes (original) (raw)

xml.sax.saxutils.XMLGenerator does not escape \r, \n, \t symbols when they are present in the attribute:

startElement("name", {"attrib": "value\nvalue"}) will result in

which will be normalized by XML parser to

According to the XML specs, to preserve this symbols in the attribute values, they should be replaced with \xD; \xA; \x9;

Trivial fix is to replace those characters in xml.sax.saxutils.writeattr