Commit Graph

763 Commits

Author SHA1 Message Date
Mike Welsh 614903bdec swf: Remove panic when data left over in tag 2019-10-10 21:52:41 -07:00
Mike Welsh 800147043a swf: Try to recover from incorrect zlib streams
Some SWFs are compressed incorrectly, often with incorrect
compressed/uncompressed lengths, causing the zlib decoders
to vomit if you try to decompress them fully. However, often times
the data still decompresses all the way to the End tag, and we
still want to try to play it even if it's corrupt.
Now these errors only omit a warning, and we'll continue to run
the SWF.

Addresses #86.
2019-10-10 13:41:43 -07:00
Mike Welsh 93a221aea4 swf: Add tests for errors on incorrect parse 2019-10-10 00:55:09 -07:00
Mike Welsh 3058b88011 swf: Add custom error type for SWF/AVM1 parse errors
Improves the error handling for the swf crate:

 * Custom swf::error::Error type added to handle various errors
   in SWF parsing.
 * Invalid parsing of tags/AVM1 ops results in a Error::ParseError
   that can include info about the underlying failure.
 * Implement Display for these errors. Output descriptive
   names for the tag/opcode when it fails to parse.
 * Handle out of bounds reads in avm1::Reader::read_slice.
   Previously this would panic, now it returns an io::Error.

Closes #85.
2019-10-10 00:55:09 -07:00
Mike Welsh 40722dcef0
avm1: Merge#81, add property attributes
Added object property attributes
2019-10-09 10:24:21 -07:00
Mike Welsh 8063d9e55c
avm1: Merge #83, add better support for comparison ops
Enhanced comparison support
2019-10-09 10:15:47 -07:00
Will Brindle ba939fc00b chore: add comment explaining the weird NaN situation 2019-10-09 06:17:41 +01:00
Will Brindle 32554e271f chore: remove trailing whitespace 2019-10-08 21:40:15 +01:00
Will Brindle f84f807bf1 core: refactor to make use of equality implementation 2019-10-08 21:36:50 +01:00
Will Brindle 70b7b1c807 chore: fix clippy & fmt issues 2019-10-08 21:04:26 +01:00
Will Brindle 6508ec6b6c core: nan equality 2019-10-08 20:51:21 +01:00
Will Brindle 0814b17fd8 chore: add tests for equality and greaterthan 2019-10-08 20:45:39 +01:00
Will Brindle e2c7af5cda core: fix boolean strict comparison 2019-10-08 19:59:32 +01:00
Will Brindle 9cf381b0e0 core: add support for actions GreaterThan, StringGreaterThan and StrictEquals 2019-10-08 19:59:32 +01:00
Nathan Adams d697d03cf0 Drop the `Attribute::` everywhere 2019-10-08 20:35:23 +02:00
Mike Welsh fb442688cb chore: Change edit_text.rs to LF line endings 2019-10-08 11:15:15 -07:00
Nathan Adams 3d09ec81e2 Add Attribute::DontEnum 2019-10-08 16:36:39 +02:00
Nathan Adams f782aaee18 Add Attribute::ReadOnly 2019-10-08 15:24:57 +02:00
Nathan Adams f2a4000ee2 Added object property attributes (initially just DontDelete) 2019-10-08 14:30:36 +02:00
Will Brindle 4856efe7d8 chore: add integration tests for typeof 2019-10-08 02:59:26 -07:00
Will Brindle 2e3748438a core: define globals for NaN, Infinity, -Infinity. Should fix `typeof NaN` 2019-10-08 02:59:26 -07:00
Mike Welsh 3fddb659fb swf: Fix incorrect parsing of clip actions in SWFv5
Clip action flags in SWFv5 are only 2 bytes big.
2019-10-08 02:13:53 -07:00
Mike Welsh 0506b7c566 web: Calculate bounds for text glyphs when not present
The text bounds fields for a DefineFont2/3 tag can be a bogus empty
rectangle, per the SWF spec. We must properly the bounds ourselves
to render properly on web.
2019-10-07 23:23:45 -07:00
Mike Welsh 3b288272d4 text: Hack to skip HTML in dynamic text fields 2019-10-07 23:23:45 -07:00
Mike Welsh eded29ce6d text: Add dummy implementation of device text
Embed an SWF version of Noto Sans (core/assets/*) into the player.
The player will load this font and use it to render device text.

This is a quicky implementation to get dynamic device text
rendering.
2019-10-07 23:23:45 -07:00
Mike Welsh de1cedb653 core: Initial EditText implementation 2019-10-07 23:23:45 -07:00
Mike Welsh 782174aa75 swf: Make read_define_edit_text public 2019-10-07 23:23:45 -07:00
Mike Welsh 9084524580 core: Render DefineFont3 at proper size (fixes #47)
Per SWF19, shape coordinates in DefineFont3 are at 20x the size of
DefineFont1/2.
2019-10-07 12:05:27 -07:00
Mike Welsh 574ede0541 avm1: Return proper root object for Avm1::root_object
Was returning start_clip instead. Also call
DisplayObject::post_instantiation for root after it's created in
Player::new.
2019-10-07 01:36:05 -07:00
Mike Welsh 4477e8458f avm1: Return dummy value 1 for getBytesLoaded/getBytesTotal
Previously returned 0 which would cause divide by 0 in many
preloaders.
2019-10-07 00:33:30 -07:00
Mike Welsh 7ed4ea0a2b tests: Rename integration_tests -> regression_tests 2019-10-06 23:58:52 -07:00
Mike Welsh aa9dcf5b0e
core: Merge pull request #63 (DefineFunction support)
AVM1 DefineFunction support
2019-10-06 18:36:48 -07:00
Mike Welsh 18a3494de2 chore: Typo supress -> suppress 2019-10-06 15:24:38 -07:00
Mike Welsh b6eba80ebd chore: cargo fmt 2019-10-06 14:57:43 -07:00
Mike Welsh 1c3e4406b3 chore: Fix clippy lints
* Remove clone calls from Copy objects
 * Used Iterator::cloned() instead of manually cloning
 * Pass swf::Function into AvmFunction2::new()
 * Use action_clone_sprite
2019-10-06 14:57:36 -07:00
David Wendt 2d365856a7 Fix tellTarget being broken by the introduction of scopes. We now create a new scope chain based off the selected active clip. 2019-10-06 13:02:31 -07:00
David Wendt 588b2bb061 Fixes to make tests compile again 2019-10-06 13:02:31 -07:00
David Wendt 5873eefb06 Since it is possible to have virtual properties in the scope chain, overwriting them should trigger their setters.
Define, since it's intended for setting locals only, always uses force-set and does not trigger setters.
2019-10-06 13:02:31 -07:00
David Wendt 06d0cf5ed1 Add a stern warning to be triggered if multiple readers are open at once. 2019-10-06 13:02:31 -07:00
David Wendt 8ed09e22ba Refactor: Since `function.rs` handles calling conventions it should just hand the avm an activation object directly 2019-10-06 13:02:31 -07:00
David Wendt cf5420e2e1 Implement register preloading, for variables we already have implemented. 2019-10-06 13:02:31 -07:00
David Wendt 8734c036a7 Removed unused function 2019-10-06 13:02:31 -07:00
David Wendt 91cbbb4e9c `ActionWaitForFrame`/`2` should not create their own readers either. 2019-10-06 13:02:31 -07:00
David Wendt a5865d7c7d Implement DefineFunction2 2019-10-06 13:02:31 -07:00
David Wendt ec1b5c457e Allow activations to hold their own private register set. 2019-10-06 13:02:31 -07:00
David Wendt d822a35404 Fix `ActionIf` and `ActionJump` 2019-10-06 13:02:31 -07:00
David Wendt 171cb9f014 GetMember needs to support string coercions (e.g. `array[1]` should work) 2019-10-06 13:02:31 -07:00
David Wendt deecd85c81 Implement `SetMember` 2019-10-06 13:02:31 -07:00
David Wendt 697a02bd05 Implement `GetMember` 2019-10-06 13:02:31 -07:00
David Wendt 51a7b426fd Implement registers, including register pushes and `ActionStoreRegister`. 2019-10-06 13:02:31 -07:00