Skip to content

Commit

Permalink
Allow ?metadata even when the C-T is unlisted in allowedImageSourceCo…
Browse files Browse the repository at this point in the history
…ntentTypes.
  • Loading branch information
papandreou committed Nov 9, 2016
1 parent 33fab6f commit 8e27f0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/processImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ module.exports = function (options) {

var contentType = res.getHeader('Content-Type');

if (contentType && (!options.allowedImageSourceContentTypes || options.allowedImageSourceContentTypes.indexOf(contentType) !== -1) && (contentType.indexOf('image/') === 0 || isMetadataRequest)) {
if (isMetadataRequest || (contentType && (options.allowedImageSourceContentTypes ? options.allowedImageSourceContentTypes.indexOf(contentType) !== -1 : contentType.indexOf('image/') === 0))) {
sourceMetadata = {
contentType: contentType,
filesize: contentLengthHeaderValue && parseInt(contentLengthHeaderValue, 10),
Expand Down
11 changes: 11 additions & 0 deletions test/processImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,17 @@ describe('express-processimage', function () {
});
});

it('should allow retrieving the metadata of a non-image file with a non-image extension, even when unlisted in allowedImageSourceContentTypes', function () {
config.allowedImageSourceContentTypes = ['image/png'];
return expect('GET /something.txt?metadata', 'to yield response', {
body: {
contentType: 'text/plain; charset=UTF-8',
filesize: 4,
etag: expect.it('to be a string')
}
});
});

it('should set animated:true for an animated gif', function () {
return expect('GET /animated.gif?metadata', 'to yield response', {
body: {
Expand Down

0 comments on commit 8e27f0e

Please sign in to comment.