pdf-parser.js 5.2.17 → 5.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -176,15 +176,15 @@ function matchesAscii(bytes, offset, text) {
|
|
|
176
176
|
for (let i = 0; i < text.length; i++) if (bytes[offset + i] !== text.charCodeAt(i)) return false;
|
|
177
177
|
return true;
|
|
178
178
|
}
|
|
179
|
-
const TYPE1_CLEARTEXT_TERMINATOR = "eexec";
|
|
180
179
|
const PFB_SEGMENT_MARKER = 128;
|
|
181
180
|
const PFB_SEGMENT_HEADER_SIZE = 6;
|
|
182
|
-
const POSTSCRIPT_MAGIC = "%!";
|
|
183
181
|
function type1Sources(bytes) {
|
|
182
|
+
const cleartextTerminator = "eexec";
|
|
183
|
+
const postScriptMagic = "%!";
|
|
184
184
|
const start = bytes[0] === PFB_SEGMENT_MARKER ? PFB_SEGMENT_HEADER_SIZE : 0;
|
|
185
|
-
if (!matchesAscii(bytes, start,
|
|
185
|
+
if (!matchesAscii(bytes, start, postScriptMagic)) return;
|
|
186
186
|
let cleartextEnd = bytes.length;
|
|
187
|
-
for (let i = start; i + 5 <= bytes.length; i++) if (matchesAscii(bytes, i,
|
|
187
|
+
for (let i = start; i + 5 <= bytes.length; i++) if (matchesAscii(bytes, i, cleartextTerminator)) {
|
|
188
188
|
cleartextEnd = i;
|
|
189
189
|
break;
|
|
190
190
|
}
|
package/dist/builtin-encoding.js
CHANGED
|
@@ -175,15 +175,15 @@ function matchesAscii(bytes, offset, text) {
|
|
|
175
175
|
for (let i = 0; i < text.length; i++) if (bytes[offset + i] !== text.charCodeAt(i)) return false;
|
|
176
176
|
return true;
|
|
177
177
|
}
|
|
178
|
-
const TYPE1_CLEARTEXT_TERMINATOR = "eexec";
|
|
179
178
|
const PFB_SEGMENT_MARKER = 128;
|
|
180
179
|
const PFB_SEGMENT_HEADER_SIZE = 6;
|
|
181
|
-
const POSTSCRIPT_MAGIC = "%!";
|
|
182
180
|
function type1Sources(bytes) {
|
|
181
|
+
const cleartextTerminator = "eexec";
|
|
182
|
+
const postScriptMagic = "%!";
|
|
183
183
|
const start = bytes[0] === PFB_SEGMENT_MARKER ? PFB_SEGMENT_HEADER_SIZE : 0;
|
|
184
|
-
if (!matchesAscii(bytes, start,
|
|
184
|
+
if (!matchesAscii(bytes, start, postScriptMagic)) return;
|
|
185
185
|
let cleartextEnd = bytes.length;
|
|
186
|
-
for (let i = start; i + 5 <= bytes.length; i++) if (matchesAscii(bytes, i,
|
|
186
|
+
for (let i = start; i + 5 <= bytes.length; i++) if (matchesAscii(bytes, i, cleartextTerminator)) {
|
|
187
187
|
cleartextEnd = i;
|
|
188
188
|
break;
|
|
189
189
|
}
|
|
@@ -64,9 +64,8 @@ function filterBpp(bitDepth, channels) {
|
|
|
64
64
|
}
|
|
65
65
|
function unpackRow(rowBytes, width, channels, bitDepth) {
|
|
66
66
|
const sampleCount = width * channels;
|
|
67
|
-
const samples =
|
|
68
|
-
if (bitDepth ===
|
|
69
|
-
else if (bitDepth === 16) for (let i = 0; i < sampleCount; i++) samples[i] = rowBytes[i * 2];
|
|
67
|
+
const samples = Array.from({ length: sampleCount });
|
|
68
|
+
if (bitDepth === 16) for (let i = 0; i < sampleCount; i++) samples[i] = rowBytes[i * 2];
|
|
70
69
|
else {
|
|
71
70
|
const mask = (1 << bitDepth) - 1;
|
|
72
71
|
for (let i = 0; i < sampleCount; i++) {
|
|
@@ -146,7 +145,6 @@ function buildRawImage(ihdr, channels, bytesPerRow, unfiltered, palette, trns) {
|
|
|
146
145
|
}
|
|
147
146
|
} else if (colorType === 3) {
|
|
148
147
|
const index = samples[pixelBase];
|
|
149
|
-
if (palette === void 0) throw new Error("indexed-colour PNG has no PLTE chunk");
|
|
150
148
|
data[outBase] = palette[index * 3];
|
|
151
149
|
data[outBase + 1] = palette[index * 3 + 1];
|
|
152
150
|
data[outBase + 2] = palette[index * 3 + 2];
|
|
@@ -164,12 +162,7 @@ function buildRawImage(ihdr, channels, bytesPerRow, unfiltered, palette, trns) {
|
|
|
164
162
|
}
|
|
165
163
|
}
|
|
166
164
|
}
|
|
167
|
-
return
|
|
168
|
-
width,
|
|
169
|
-
height,
|
|
170
|
-
channels: outChannels,
|
|
171
|
-
data
|
|
172
|
-
} : {
|
|
165
|
+
return {
|
|
173
166
|
width,
|
|
174
167
|
height,
|
|
175
168
|
channels: outChannels,
|
package/dist/image/png-decode.js
CHANGED
|
@@ -63,9 +63,8 @@ function filterBpp(bitDepth, channels) {
|
|
|
63
63
|
}
|
|
64
64
|
function unpackRow(rowBytes, width, channels, bitDepth) {
|
|
65
65
|
const sampleCount = width * channels;
|
|
66
|
-
const samples =
|
|
67
|
-
if (bitDepth ===
|
|
68
|
-
else if (bitDepth === 16) for (let i = 0; i < sampleCount; i++) samples[i] = rowBytes[i * 2];
|
|
66
|
+
const samples = Array.from({ length: sampleCount });
|
|
67
|
+
if (bitDepth === 16) for (let i = 0; i < sampleCount; i++) samples[i] = rowBytes[i * 2];
|
|
69
68
|
else {
|
|
70
69
|
const mask = (1 << bitDepth) - 1;
|
|
71
70
|
for (let i = 0; i < sampleCount; i++) {
|
|
@@ -145,7 +144,6 @@ function buildRawImage(ihdr, channels, bytesPerRow, unfiltered, palette, trns) {
|
|
|
145
144
|
}
|
|
146
145
|
} else if (colorType === 3) {
|
|
147
146
|
const index = samples[pixelBase];
|
|
148
|
-
if (palette === void 0) throw new Error("indexed-colour PNG has no PLTE chunk");
|
|
149
147
|
data[outBase] = palette[index * 3];
|
|
150
148
|
data[outBase + 1] = palette[index * 3 + 1];
|
|
151
149
|
data[outBase + 2] = palette[index * 3 + 2];
|
|
@@ -163,12 +161,7 @@ function buildRawImage(ihdr, channels, bytesPerRow, unfiltered, palette, trns) {
|
|
|
163
161
|
}
|
|
164
162
|
}
|
|
165
163
|
}
|
|
166
|
-
return
|
|
167
|
-
width,
|
|
168
|
-
height,
|
|
169
|
-
channels: outChannels,
|
|
170
|
-
data
|
|
171
|
-
} : {
|
|
164
|
+
return {
|
|
172
165
|
width,
|
|
173
166
|
height,
|
|
174
167
|
channels: outChannels,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdf-parser.js",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.19",
|
|
4
4
|
"description": "Hand-written, dependency-minimal PDF codec: parses arbitrary real-world PDFs and generates new ones, built on its own codec-owned LayoutDocument item model and Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|