Skip to content

Commit 1cf10b5

Browse files
committed
Escape TAB/LF/CR again when serializing to XML
XML.mustEscape() is shared by XML.escape() (serialization) and XMLTokener.unescapeEntity() (parsing), but the two callers need opposite answers for #x9/#xA/#xD. #1070 added those codepoints to the valid-range clause to fix unescape("
"), which also stopped XML.toString() and JSONML.toString() from escaping literal TAB, LF and CR. Literal occurrences of these characters are subject to whitespace normalization by conforming XML parsers, so a value like "Lettuce\nTomato" loses its line breaks when the generated XML is read back by any standard parser. This regressed #1092. Split the two concerns: mustEscape() returns true for every ISO control character again (serialization), and the new isValidXmlCharacter() checks the XML 1.0 character range for numeric character references during parsing. unescapeEntity() now validates with isValidXmlCharacter(), so 	, 
 and 
 keep being accepted (#1059/#1070 behavior unchanged). Fixes #1092
1 parent 69383f7 commit 1cf10b5

0 file changed

File tree

    0 commit comments

    Comments
     (0)