avm1: onData fails if the loaded data is an empty string

This commit is contained in:
Toad06 2022-11-14 00:05:18 +01:00 committed by kmeisthax
parent b3debc96af
commit 182c3b78e4
1 changed files with 11 additions and 5 deletions

View File

@ -938,13 +938,19 @@ impl<'gc> Loader<'gc> {
);
// Fire the onData method with the loaded string.
let string_data = AvmString::new_utf8(
// If the loaded data is an empty string, the load is considered unsuccessful.
let value_data = if response.body.is_empty() {
Value::Undefined
} else {
AvmString::new_utf8(
activation.context.gc_context,
UTF_8.decode(&response.body).0,
);
)
.into()
};
let _ = that.call_method(
"onData".into(),
&[string_data.into()],
&[value_data],
&mut activation,
ExecutionReason::Special,
);