foliojs / brotli.js

A JavaScript port of the Brotli compression algorithm, as used in WOFF2
494 stars 51 forks source link

Fix decompression of data with multple meta-blocks #7

Closed jechter closed 8 years ago

jechter commented 8 years ago

Currently, brotli.js decompression seems to fail for me for input data with multiple meta-blocks if no output_size is specified. This is because BrotliDecompressBuffer calculates output_size from the first meta block, but that will be too small if there are multiple meta blocks. This PR changes this to resize the output buffer when another meta block is found, and the output buffer size is too small to fit it's contents.

devongovett commented 8 years ago

Can you add a test file demonstrating the issue?

jechter commented 8 years ago

This file should demonstrate the issue: http://files.unity3d.com/jonas/test.brotli - but not sure it is reasonable to commit a file of this size to the repo?

jechter commented 8 years ago

Added additional fixes for running out of input when reading context modes, and for prev_byte1,2 not being valid after uncompressed blocks.

devongovett commented 8 years ago

Thanks!