mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Guard against InitImage failure #150
Protects against truncated image headers
This commit is contained in:
@@ -292,6 +292,22 @@ describe('Input/output', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('File input with corrupt header fails gracefully', function(done) {
|
||||
sharp(fixtures.inputJpgWithCorruptHeader)
|
||||
.toBuffer(function(err) {
|
||||
assert.strictEqual(true, !!err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Buffer input with corrupt header fails gracefully', function(done) {
|
||||
sharp(fs.readFileSync(fixtures.inputJpgWithCorruptHeader))
|
||||
.toBuffer(function(err) {
|
||||
assert.strictEqual(true, !!err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Output filename without extension uses input format', function() {
|
||||
|
||||
it('JPEG', function(done) {
|
||||
|
||||
@@ -216,4 +216,20 @@ describe('Image metadata', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('File input with corrupt header fails gracefully', function(done) {
|
||||
sharp(fixtures.inputJpgWithCorruptHeader)
|
||||
.metadata(function(err) {
|
||||
assert.strictEqual(true, !!err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Buffer input with corrupt header fails gracefully', function(done) {
|
||||
sharp(fs.readFileSync(fixtures.inputJpgWithCorruptHeader))
|
||||
.metadata(function(err) {
|
||||
assert.strictEqual(true, !!err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user