avm2+tests: Support CData in XML.toXMLString; add test

This commit is contained in:
Lord-McSweeney 2023-06-24 20:29:09 -07:00 committed by Aaron Hill
parent f24aabf74e
commit 2d02886f5a
4 changed files with 13 additions and 3 deletions

View File

@ -681,10 +681,15 @@ fn to_xml_string_inner<'gc>(xml: E4XOrXml<'gc>, buf: &mut WString) -> Result<(),
} }
E4XNodeKind::Attribute(_) E4XNodeKind::Attribute(_)
| E4XNodeKind::Comment(_) | E4XNodeKind::Comment(_)
| E4XNodeKind::ProcessingInstruction(_) | E4XNodeKind::ProcessingInstruction(_) => {
| E4XNodeKind::CData(_) => {
return Err(format!("ToXMLString: Not yet implemented node {:?}", node_kind).into()) return Err(format!("ToXMLString: Not yet implemented node {:?}", node_kind).into())
} }
E4XNodeKind::CData(data) => {
buf.push_utf8("<![CDATA[");
buf.push_str(data);
buf.push_utf8("]]>");
return Ok(());
}
E4XNodeKind::Element { E4XNodeKind::Element {
children, children,
attributes, attributes,

View File

@ -61,6 +61,7 @@ CDATA
]]>; ]]>;
trace(cdata); trace(cdata);
trace(cdata.toXMLString());
var declaration_doctype = new XML("<?xml version = \"1.0\" encoding = \"UTF-8\" standalone = \"yes\" ?> <!DOCTYPE person [<!ELEMENT name (#PCDATA)> ]> <p>Skipped everything else</p>"); var declaration_doctype = new XML("<?xml version = \"1.0\" encoding = \"UTF-8\" standalone = \"yes\" ?> <!DOCTYPE person [<!ELEMENT name (#PCDATA)> ]> <p>Skipped everything else</p>");
trace(declaration_doctype.toString()); trace(declaration_doctype.toString());

View File

@ -22,6 +22,10 @@ My
Multiline Multiline
CDATA CDATA
<![CDATA[My
Multiline
CDATA
]]>
Skipped everything else Skipped everything else
Text after comments and PI Text after comments and PI
Empty lists: 0 0 Empty lists: 0 0