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::Comment(_)
| E4XNodeKind::ProcessingInstruction(_)
| E4XNodeKind::CData(_) => {
| E4XNodeKind::ProcessingInstruction(_) => {
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 {
children,
attributes,

View File

@ -61,6 +61,7 @@ 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>");
trace(declaration_doctype.toString());
@ -84,4 +85,4 @@ trace(declaration_doctype.toString());
}
}
Test.run();
Test.run();

View File

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