-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
zlib: add maxOutputLength
option
#33516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,24 @@ | ||||||||||||||||
'use strict'; | ||||||||||||||||
require('../common'); | ||||||||||||||||
const assert = require('assert'); | ||||||||||||||||
const zlib = require('zlib'); | ||||||||||||||||
|
||||||||||||||||
const encoded = Buffer.from('G38A+CXCIrFAIAM=', 'base64'); | ||||||||||||||||
|
||||||||||||||||
// Async | ||||||||||||||||
zlib.brotliDecompress(encoded, { maxOutputLength: 64 }, function(err) { | ||||||||||||||||
rosaxxny marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
assert.ok(err instanceof RangeError); | ||||||||||||||||
}); | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @BridgeAR Suggestion applied in latest commit. |
||||||||||||||||
|
||||||||||||||||
// Sync | ||||||||||||||||
assert.throws(function() { | ||||||||||||||||
zlib.brotliDecompressSync(encoded, { maxOutputLength: 64 }); | ||||||||||||||||
}, RangeError); | ||||||||||||||||
|
||||||||||||||||
// Async | ||||||||||||||||
zlib.brotliDecompress(encoded, { maxOutputLength: 256 }, function(err) { | ||||||||||||||||
rosaxxny marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
assert.strictEqual(err, null); | ||||||||||||||||
}); | ||||||||||||||||
Comment on lines
+20
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
|
||||||||||||||||
// Sync | ||||||||||||||||
zlib.brotliDecompressSync(encoded, { maxOutputLength: 256 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we at least check that
this._maxOutputLength
is a (positive) number during this initialization?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above there's a check for 'opts` there the following code could be used:
And here:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BridgeAR Suggestion applied in latest commit.