-
-
Notifications
You must be signed in to change notification settings - Fork 809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swf: SWF parsing returns slices of input, use Windows-1252 string encoding in SWFv5 #2636
Conversation
Tested the PR on the web backend and it works perfectly, very impressed how much stuff this PR fixes. 👍 Just a little thing, it seems like every file always logs this warning: A last thing, but possibly unrelated, this (not legit) file cannot be parsed because of unknown tags 903 and 1002 (I've never seen those values in any other files I've tested). |
Avoid copies by returning slices of the decompressed input.
* SwfRead -> SwfReadExt * SwfWrite -> SwfWriteExt * read_swf_header -> decompress_swf * read_swf -> parse_swf
Fixed!
Looks like the file is contains these bogus tags for whatever reason. (Ffdec shows the same tag #s). |
a065218
to
d20ff15
Compare
SwfStr is now an unsized slice analogous to `str` or `bstr`. The desired encoding must be supplied when converting to String.
Start some much needed spring cleaning of
swf
:bitstream_io
for bit parsing. Add areader.bits()
that returns the bitstream reader on demand, which gives clear boundaries between byte-aligned and bit-packed structs.swf::Tag
structs to return slices for raw data and strings instead of copying. This fixes remaining issues with out-of-bounds jumps in clip/button actions. (fixes Miami Shark - Start Game button doesn't do anything #1397, Mspacman keys not working #2442, SCANDAL: Bloons Tower Defense 1&2 not working #2618, ...)swf::SwfStr
type to handle string encoding.SwfStr
is a sequence of bytes (allowing for invalid encodings) and can be decoded based on the SWF version, usingencoding_rs
to decode when necessary. This fixes the parsing of various early SWFs with non-ASCII (fixes swf: Fall back to WINDOWS-1252 for text decoding #1499, Steppenwolf 4-3 cannot be parsed #1533, Error running definition tag: DefineEditText, got Invalid data #1903, Animation skips to the end and goes into a loop #2043, ...) and will also allow us to make the encoding configurable.Cursor
from throughout the APIs.TODO (probably future PRs):
bitflags
or for some of the dense bitflags in various swf structs. (Many of the structs have long lists of bools).read_swf
reading a sequence of owned tags.Reader
struct. Ruffle core can use these free functions directly.Reader
etc. could be reintroduced as part of the above convenience API inswf
.AvmString
representation to work similar toSwfString
.