mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-03-04 16:25:17 +00:00
Since decompression can increase the memory usage non-linearly, add a `config.maxDecompressedMessageSize` option to limit the decompressed message size. By default it's set to `Infinity`, i.e. no limit. Set the config option to a number of bytes to limit the size of data that gets decompressed. Also, handle backpressure in fflate fallback; don't start (de)compressing more data if the (de)compressed data stream reader hasn't asked for more data yet. Finally, split the input chunks so that we don't overwhelm the output stream with a lot of data if the input chunks are very large, as the fflate fallback and WebKit's implementation of the native Compression API seem to decompress the input chunks completely before producing an output chunk, which doesn't give us a chance to cancel the decompression if too much data is provided.