avm1: onData fails if the loaded data is an empty string
This commit is contained in:
parent
b3debc96af
commit
182c3b78e4
|
@ -938,13 +938,19 @@ impl<'gc> Loader<'gc> {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Fire the onData method with the loaded string.
|
// 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.
|
||||||
activation.context.gc_context,
|
let value_data = if response.body.is_empty() {
|
||||||
UTF_8.decode(&response.body).0,
|
Value::Undefined
|
||||||
);
|
} else {
|
||||||
|
AvmString::new_utf8(
|
||||||
|
activation.context.gc_context,
|
||||||
|
UTF_8.decode(&response.body).0,
|
||||||
|
)
|
||||||
|
.into()
|
||||||
|
};
|
||||||
let _ = that.call_method(
|
let _ = that.call_method(
|
||||||
"onData".into(),
|
"onData".into(),
|
||||||
&[string_data.into()],
|
&[value_data],
|
||||||
&mut activation,
|
&mut activation,
|
||||||
ExecutionReason::Special,
|
ExecutionReason::Special,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue