mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-10 22:00:58 +01:00
Inflate: use max window size by default, #174
This commit is contained in:
parent
4e8ff8e74a
commit
ec116f6f40
5 changed files with 21 additions and 2 deletions
|
@ -101,7 +101,7 @@ const {
|
||||||
function Inflate(options) {
|
function Inflate(options) {
|
||||||
this.options = utils.assign({
|
this.options = utils.assign({
|
||||||
chunkSize: 16384,
|
chunkSize: 16384,
|
||||||
windowBits: 0,
|
windowBits: 15,
|
||||||
to: ''
|
to: ''
|
||||||
}, options || {});
|
}, options || {});
|
||||||
|
|
||||||
|
|
|
@ -471,7 +471,12 @@ const inflate = (strm, flush) => {
|
||||||
state.mode = BAD;
|
state.mode = BAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state.dmax = 1 << len;
|
|
||||||
|
// !!! pako patch. Force use `options.windowBits` if passed.
|
||||||
|
// Required to always use max window size by default.
|
||||||
|
state.dmax = 1 << state.wbits;
|
||||||
|
//state.dmax = 1 << len;
|
||||||
|
|
||||||
//Tracev((stderr, "inflate: zlib header ok\n"));
|
//Tracev((stderr, "inflate: zlib header ok\n"));
|
||||||
strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;
|
strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;
|
||||||
state.mode = hold & 0x200 ? DICTID : TYPE;
|
state.mode = hold & 0x200 ? DICTID : TYPE;
|
||||||
|
|
BIN
test/fixtures/bad_wbits.deflate
vendored
Normal file
BIN
test/fixtures/bad_wbits.deflate
vendored
Normal file
Binary file not shown.
1
test/fixtures/bad_wbits.txt
vendored
Normal file
1
test/fixtures/bad_wbits.txt
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
const zlib = require('zlib');
|
const zlib = require('zlib');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
const pako = require('../index');
|
const pako = require('../index');
|
||||||
const { testInflate, testSamples, loadSamples } = require('./helpers');
|
const { testInflate, testSamples, loadSamples } = require('./helpers');
|
||||||
|
@ -206,3 +208,14 @@ describe('Inflate with dictionary', () => {
|
||||||
testInflate(samples, { dictionary: dict.buffer }, { dictionary: dict });
|
testInflate(samples, { dictionary: dict.buffer }, { dictionary: dict });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('pako patches for inflate', () => {
|
||||||
|
|
||||||
|
it('Force use max window size by default', () => {
|
||||||
|
const data = fs.readFileSync(path.join(__dirname, 'fixtures/bad_wbits.deflate'));
|
||||||
|
const unpacked = fs.readFileSync(path.join(__dirname, 'fixtures/bad_wbits.txt'));
|
||||||
|
|
||||||
|
assert.deepStrictEqual(pako.inflate(data), new Uint8Array(unpacked));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue