djcsdy / swfmill

Generate or decompile Adobe Flash SWF files using an XML dialect. Inspect and modify the XML by hand, or by using a built in XSLT processor.
http://www.swfmill.org/
GNU General Public License v2.0
131 stars 28 forks source link

swf2xml produces invalid XML output #36

Open tuomassalo opened 8 years ago

tuomassalo commented 8 years ago

With the attached .swf file, the swf2xml command produces invalid XML. Notice the 1b in the dump.

$ swfmill swf2xml test.swf | grep '\^' | hexdump -C
00000000  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3c 53  |              <S|
00000010  74 72 69 6e 67 20 76 61  6c 75 65 3d 22 5e 1b 22  |tring value="^."|
00000020  2f 3e 0a                                          |/>.|
00000023

test.swf.zip

Since XML disallows ASCII control characters, they should be escaped or removed. Both approaches have downsides.

For someone having the same problem, here's a a quick fix to just change all control characters to spaces:

perl -pi -e 's/[\0-\x{09}\x{0b}-\x{1f}]/ /g' test.xml
djcsdy commented 7 years ago

This is a tricky one, since XML doesn’t even allow ASCII control characters to be escaped like &#x1b.