diff --git a/core/src/avm2/bytearray.rs b/core/src/avm2/bytearray.rs index 79045ab407eb..65cffc15e508 100644 --- a/core/src/avm2/bytearray.rs +++ b/core/src/avm2/bytearray.rs @@ -229,11 +229,13 @@ impl ByteArrayStorage { let mut buffer = Vec::new(); let error: Option> = match algorithm { CompressionAlgorithm::Zlib => { - let mut encoder = ZlibEncoder::new(&*self.bytes, Compression::fast()); + // Note: some content is sensitive to compression type + // (as it's visible in the header) + let mut encoder = ZlibEncoder::new(&*self.bytes, Compression::best()); encoder.read_to_end(&mut buffer).err().map(|e| e.into()) } CompressionAlgorithm::Deflate => { - let mut encoder = DeflateEncoder::new(&*self.bytes, Compression::fast()); + let mut encoder = DeflateEncoder::new(&*self.bytes, Compression::best()); encoder.read_to_end(&mut buffer).err().map(|e| e.into()) } #[cfg(feature = "lzma")] diff --git a/tests/tests/swfs/avm2/bytearray_compress/Test.as b/tests/tests/swfs/avm2/bytearray_compress/Test.as index cb205e901097..066f9c47192d 100644 --- a/tests/tests/swfs/avm2/bytearray_compress/Test.as +++ b/tests/tests/swfs/avm2/bytearray_compress/Test.as @@ -1,3 +1,5 @@ +// compiled with mxmlc + package { import flash.utils.ByteArray; import flash.utils.Endian; @@ -36,6 +38,8 @@ package { ba.uncompress("zlib"); print("uncompressed (zlib)", ba, true); + + checkZlibPrefix(); } function createByteArray(): ByteArray { @@ -68,5 +72,17 @@ package { trace(""); } + + // Issue 13773: gemcraft labirynth + // Requires zlib->base64 values to start with "eN". + // (which means binary header [120, 218]) + function checkZlibPrefix() { + trace("Checking zlib header:") + var ba = createByteArray(); + ba.compress("zlib"); + ba.position = 0; + trace(ba.readUnsignedByte()); + trace(ba.readUnsignedByte()); + } } -} \ No newline at end of file +} diff --git a/tests/tests/swfs/avm2/bytearray_compress/output.txt b/tests/tests/swfs/avm2/bytearray_compress/output.txt index 54bccdb4e601..d70b0d854347 100644 --- a/tests/tests/swfs/avm2/bytearray_compress/output.txt +++ b/tests/tests/swfs/avm2/bytearray_compress/output.txt @@ -26,3 +26,6 @@ uncompressed (zlib) position is at 0 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99 +Checking zlib header: +120 +218 diff --git a/tests/tests/swfs/avm2/bytearray_compress/test.fla b/tests/tests/swfs/avm2/bytearray_compress/test.fla deleted file mode 100644 index f4c23c5d47e4..000000000000 Binary files a/tests/tests/swfs/avm2/bytearray_compress/test.fla and /dev/null differ diff --git a/tests/tests/swfs/avm2/bytearray_compress/test.swf b/tests/tests/swfs/avm2/bytearray_compress/test.swf index 47c62d4649ce..2cb295c70a3f 100644 Binary files a/tests/tests/swfs/avm2/bytearray_compress/test.swf and b/tests/tests/swfs/avm2/bytearray_compress/test.swf differ