New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

image-headers

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-headers - npm Package Compare versions

Comparing version 0.2.7 to 0.2.8

89

lib/image_headers.js

@@ -48,20 +48,16 @@ // Generated by CoffeeScript 1.4.0

ImageHeaders.prototype.add_bytes = function(bytes) {
var b, _i, _len, _results;
var b, _i, _len;
if (this.finished === true) {
return;
}
if (this.buffer_index >= MAX_SIZE) {
this.finished = true;
return;
}
if (typeof bytes === "number") {
bytes = [bytes];
}
_results = [];
for (_i = 0, _len = bytes.length; _i < _len; _i++) {
b = bytes[_i];
if (this.finished === true) {
return;
}
if (this.exif_bytes === 0) {
this.buffer[this.buffer_index] = b;
this.route_byte(b);
this.buffer_index++;
} else {

@@ -72,5 +68,4 @@ this.exif_buffer.writeUInt8(b, this.exif_offset);

}
_results.push(this.stream_index++);
this.stream_index++;
}
return _results;
};

@@ -114,9 +109,9 @@

case ImageHeaders.modes.jpeg:
return this.check_jpeg_state(b, this.buffer_index);
return this.check_jpeg_state(b);
case ImageHeaders.modes.gif:
return this.check_gif_state(b, this.buffer_index);
return this.check_gif_state(b);
case ImageHeaders.modes.tiff:
return this.check_tiff_state(b, this.buffer_index);
return this.check_tiff_state(b);
case ImageHeaders.modes.png:
return this.check_png_state(b, this.buffer_index);
return this.check_png_state(b);
default:

@@ -127,4 +122,14 @@ return this.identify_format(b);

ImageHeaders.prototype.check_jpeg_state = function(b, i) {
var length, position;
ImageHeaders.prototype.check_jpeg_state = function(b) {
var i, length, position;
if (this.jpeg.marker === 0 && b !== 255) {
return;
}
if (this.buffer_index >= this.buffer.length) {
this.clear_jpeg_marker;
return;
}
i = this.buffer_index;
this.buffer[this.buffer_index] = b;
this.buffer_index++;
if (this.jpeg.marker === 0 && b === 255) {

@@ -157,3 +162,4 @@ this.jpeg.marker = b;

if (this.jpeg.marker === 0xDA && this.jpeg.marker_offset - i === 0) {
this.finished = true;
this.clear_jpeg_marker();
this.end_parsing();
return;

@@ -163,8 +169,2 @@ }

if (position === 2) {
if (!(this.buffer.length > this.jpeg.marker_offset + 2)) {
this.finished = true;
this.clear_jpeg_marker();
console.log("Aborting parse at " + this.jpeg.marker_offset + " " + this.jpeg.marker + " " + this.buffer.length);
return;
}
length = this.buffer.readUInt16BE(this.jpeg.marker_offset + 1);

@@ -203,12 +203,19 @@ this.jpeg.marker_size = length;

ImageHeaders.prototype.check_gif_state = function(b, i) {
ImageHeaders.prototype.check_gif_state = function(b) {
var i;
i = this.buffer_index;
this.buffer[this.buffer_index] = b;
this.buffer_index++;
if (i === 10) {
this.width = this.buffer.readUInt16LE(6);
this.height = this.buffer.readUInt16LE(8);
return this.finished = true;
return this.end_parsing();
}
};
ImageHeaders.prototype.check_png_state = function(b, i) {
var length, offset;
ImageHeaders.prototype.check_png_state = function(b) {
var i, length, offset;
i = this.buffer_index;
this.buffer[this.buffer_index] = b;
this.buffer_index++;
if (i < 8) {

@@ -232,3 +239,3 @@ return;

this.height = this.buffer.readUInt32BE(this.png.start + 12);
return this.finished = true;
return this.end_parsing();
}

@@ -244,7 +251,10 @@ break;

this.width = 0;
return this.finished = true;
return this.end_parsing();
};
ImageHeaders.prototype.identify_format = function(b) {
var buf_as_string, i, _i, _ref, _results;
var buf_as_string, i, temp_buffer, _i, _ref, _results;
i = this.buffer_index;
this.buffer[this.buffer_index] = b;
this.buffer_index++;
if (this.stream_index === 1) {

@@ -267,9 +277,12 @@ if (this.buffer[0] === 0xFF && this.buffer[1] === 0xD8) {

if (this.stream_index > 10) {
this.finished = true;
this.end_parsing();
return;
}
if ((this.mode != null)) {
temp_buffer = new Buffer(this.stream_index + 1);
this.buffer.copy(temp_buffer, 0, 0, this.stream_index + 1);
this.reset_buffer_data();
_results = [];
for (i = _i = 0, _ref = this.stream_index; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
_results.push(this.route_byte(this.buffer[i], i));
_results.push(this.route_byte(temp_buffer[i], i));
}

@@ -280,3 +293,15 @@ return _results;

ImageHeaders.prototype.reset_buffer_data = function() {
this.buffer_index = 0;
return this.buffer.slice();
};
ImageHeaders.prototype.end_parsing = function() {
this.reset_buffer_data();
this.buffer = null;
return this.finished = true;
};
ImageHeaders.prototype.clear_jpeg_marker = function() {
this.reset_buffer_data();
this.jpeg.marker = 0;

@@ -283,0 +308,0 @@ this.jpeg.marker_offset = 0;

{
"name": "image-headers",
"version": "0.2.7",
"version": "0.2.8",
"description": "Parse image headers from a stream without loading the entire image.",

@@ -5,0 +5,0 @@ "keywords": ["exif", "jpeg", "jpg", "gif", "png", "streaming"],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc