avm2: XML/XMLList is converted to a string when set as attribute value

This commit is contained in:
sleepycatcoding 2023-08-25 11:16:27 +03:00 committed by TÖRÖK Attila
parent 1b03ce9ae6
commit 75566b92e0
9 changed files with 62 additions and 9 deletions

View File

@ -312,15 +312,6 @@ impl<'gc> TObject<'gc> for XmlObject<'gc> {
if name.is_attribute() {
self.delete_property_local(activation, name)?;
if let Some(obj) = value.as_object() {
if obj.as_xml_object().is_some() || obj.as_xml_list_object().is_some() {
return Err(format!(
"Cannot set an XML/XMLList object {:?} as an attribute",
obj
)
.into());
}
}
let Some(local_name) = name.local_name() else {
return Err(format!("Cannot set attribute {:?} without a local name", name).into());
};

View File

@ -0,0 +1,21 @@
package
{
import flash.display.Sprite;
public class Test extends Sprite
{
}
}
var main:XML = <root><item>A</item></root>;
var part:XML = <hello><a>B</a><b>C</b></hello>;
trace(main);
main.item[0].@name = "Hello";
trace(main);
main.item[0].@name2 = part;
trace(main);

View File

@ -0,0 +1,9 @@
<root>
<item>A</item>
</root>
<root>
<item name="Hello">A</item>
</root>
<root>
<item name="Hello" name2="&lt;hello>&#xA; &lt;a>B&lt;/a>&#xA; &lt;b>C&lt;/b>&#xA;&lt;/hello>">A</item>
</root>

Binary file not shown.

View File

@ -0,0 +1 @@
num_ticks = 1

View File

@ -0,0 +1,21 @@
package
{
import flash.display.Sprite;
public class Test extends Sprite
{
}
}
var main:XML = <root><item>A</item></root>;
var part:XMLList = new XMLList("<root><item>A</item><item>B</item></root>");
trace(main);
main.item[0].@name = "Hello";
trace(main);
main.item[0].@name2 = part;
trace(main);

View File

@ -0,0 +1,9 @@
<root>
<item>A</item>
</root>
<root>
<item name="Hello">A</item>
</root>
<root>
<item name="Hello" name2="&lt;root>&#xA; &lt;item>A&lt;/item>&#xA; &lt;item>B&lt;/item>&#xA;&lt;/root>">A</item>
</root>

Binary file not shown.

View File

@ -0,0 +1 @@
num_ticks = 1