avm2: Throw error when using descendants op (..) on anything that isn't XML, even if it has descendants property

This commit is contained in:
Nathan Adams 2023-08-02 10:52:49 +02:00
parent 690ce110d8
commit 42b4812601
2 changed files with 27 additions and 7 deletions

View File

@ -1775,12 +1775,33 @@ impl<'a, 'gc> Activation<'a, 'gc> {
) -> Result<FrameControl<'gc>, Error<'gc>> { ) -> Result<FrameControl<'gc>, Error<'gc>> {
let multiname = self.pool_multiname_and_initialize(method, index)?; let multiname = self.pool_multiname_and_initialize(method, index)?;
let object = self.pop_stack().coerce_to_object_or_typeerror(self, None)?; let object = self.pop_stack().coerce_to_object_or_typeerror(self, None)?;
if object.as_xml_object().is_some() || object.as_xml_list_object().is_some() {
let descendants = object.call_public_property( let descendants = object.call_public_property(
"descendants", "descendants",
&[QNameObject::from_name(self, (*multiname).clone())?.into()], &[QNameObject::from_name(self, (*multiname).clone())?.into()],
self, self,
)?; )?;
self.push_stack(descendants); self.push_stack(descendants);
} else {
// Even if it's an object with the "descendants" property, we won't support it.
let class_name = object
.instance_of()
.map(|cls| {
cls.inner_class_definition()
.read()
.name()
.to_qualified_name_err_message(self.context.gc_context)
})
.unwrap_or_else(|| AvmString::from("<UNKNOWN>"));
return Err(Error::AvmError(type_error(
self,
&format!(
"Error #1016: Descendants operator (..) not supported on type {}",
class_name
),
1016,
)?));
}
Ok(FrameControl::Continue) Ok(FrameControl::Continue)
} }

View File

@ -1,2 +1 @@
num_ticks = 1 num_ticks = 1
known_failure = true