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

@react-pdf/image

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-pdf/image - npm Package Compare versions

Comparing version 2.3.1 to 2.3.2

48

lib/index.browser.js

@@ -5,3 +5,3 @@ import _regeneratorRuntime from '@babel/runtime/helpers/regeneratorRuntime';

import PNG from '@react-pdf/png-js';
import exif from 'jpeg-exif';
import _JPEG from 'jay-peg';

@@ -1988,3 +1988,2 @@ var global$1 = (typeof global !== "undefined" ? global :

var MARKERS = [0xffc0, 0xffc1, 0xffc2, 0xffc3, 0xffc5, 0xffc6, 0xffc7, 0xffc8, 0xffc9, 0xffca, 0xffcb, 0xffcc, 0xffcd, 0xffce, 0xffcf];
var JPEG = function JPEG(data) {

@@ -1998,22 +1997,13 @@ this.data = null;

}
var marker;
var pos = 2;
// Parse the EXIF orientation
this.orientation = exif.fromBuffer(this.data).Orientation || 1;
while (pos < data.length) {
marker = data.readUInt16BE(pos);
pos += 2;
if (MARKERS.includes(marker)) {
break;
var markers = _JPEG.decode(this.data);
for (var i = 0; i < markers.length; i += 1) {
var marker = markers[i];
if (marker.name === 'EXIF' && marker.entries.orientation) {
this.orientation = marker.entries.orientation;
}
pos += data.readUInt16BE(pos);
if (marker.name === 'SOF') {
this.width || (this.width = marker.width);
this.height || (this.height = marker.height);
}
}
if (!MARKERS.includes(marker)) {
throw new Error('Invalid JPEG.');
}
pos += 3;
this.height = data.readUInt16BE(pos);
pos += 2;
this.width = data.readUInt16BE(pos);
if (this.orientation > 4) {

@@ -2026,19 +2016,3 @@ var _ref = [this.height, this.width];

JPEG.isValid = function (data) {
if (!data || !Buffer.isBuffer(data) || data.readUInt16BE(0) !== 0xffd8) {
return false;
}
var marker;
var pos = 2;
while (pos < data.length) {
marker = data.readUInt16BE(pos);
pos += 2;
if (MARKERS.includes(marker)) {
break;
}
pos += data.readUInt16BE(pos);
}
if (!MARKERS.includes(marker)) {
return false;
}
return true;
return data && Buffer.isBuffer(data) && data.readUInt16BE(0) === 0xffd8;
};

@@ -2045,0 +2019,0 @@

@@ -8,3 +8,3 @@ import _regeneratorRuntime from '@babel/runtime/helpers/regeneratorRuntime';

import PNG from '@react-pdf/png-js';
import exif from 'jpeg-exif';
import _JPEG from 'jay-peg';

@@ -19,3 +19,2 @@ PNG.isValid = function isValid(data) {

var MARKERS = [0xffc0, 0xffc1, 0xffc2, 0xffc3, 0xffc5, 0xffc6, 0xffc7, 0xffc8, 0xffc9, 0xffca, 0xffcb, 0xffcc, 0xffcd, 0xffce, 0xffcf];
var JPEG = function JPEG(data) {

@@ -29,22 +28,13 @@ this.data = null;

}
var marker;
var pos = 2;
// Parse the EXIF orientation
this.orientation = exif.fromBuffer(this.data).Orientation || 1;
while (pos < data.length) {
marker = data.readUInt16BE(pos);
pos += 2;
if (MARKERS.includes(marker)) {
break;
var markers = _JPEG.decode(this.data);
for (var i = 0; i < markers.length; i += 1) {
var marker = markers[i];
if (marker.name === 'EXIF' && marker.entries.orientation) {
this.orientation = marker.entries.orientation;
}
pos += data.readUInt16BE(pos);
if (marker.name === 'SOF') {
this.width || (this.width = marker.width);
this.height || (this.height = marker.height);
}
}
if (!MARKERS.includes(marker)) {
throw new Error('Invalid JPEG.');
}
pos += 3;
this.height = data.readUInt16BE(pos);
pos += 2;
this.width = data.readUInt16BE(pos);
if (this.orientation > 4) {

@@ -57,19 +47,3 @@ var _ref = [this.height, this.width];

JPEG.isValid = function (data) {
if (!data || !Buffer.isBuffer(data) || data.readUInt16BE(0) !== 0xffd8) {
return false;
}
var marker;
var pos = 2;
while (pos < data.length) {
marker = data.readUInt16BE(pos);
pos += 2;
if (MARKERS.includes(marker)) {
break;
}
pos += data.readUInt16BE(pos);
}
if (!MARKERS.includes(marker)) {
return false;
}
return true;
return data && Buffer.isBuffer(data) && data.readUInt16BE(0) === 0xffd8;
};

@@ -76,0 +50,0 @@

{
"name": "@react-pdf/image",
"version": "2.3.1",
"version": "2.3.2",
"license": "MIT",

@@ -28,3 +28,3 @@ "description": "Parses the images in png or jpeg format for react-pdf document",

"scripts": {
"test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest",
"test": "vitest",
"build": "rimraf ./lib && rollup -c",

@@ -37,7 +37,4 @@ "watch": "rimraf ./lib && rollup -c -w"

"cross-fetch": "^3.1.5",
"jpeg-exif": "^1.1.4"
"jay-peg": "^1.0.0"
},
"devDependencies": {
"jest-fetch-mock": "^2.1.1"
},
"files": [

@@ -44,0 +41,0 @@ "lib"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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