Skip to content

Commit 08d48f6

Browse files
authored
fix: issue #428: resolve obj ref before invoking getAll (#419)
* fix: issue #418: resolve object ref before calling getAll * fix: add test PDF for #418
1 parent 399f9cb commit 08d48f6

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

base/shared/colorspace.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,10 @@ var ColorSpace = (function ColorSpaceClosure() {
212212
case 'CMYK':
213213
return 'DeviceCmykCS';
214214
case 'CalGray':
215-
var params = cs[1].getAll();
215+
var params = xref.fetchIfRef(cs[1]);
216+
if (isDict(params)) {
217+
params = params.getAll();
218+
}
216219
return ['CalGrayCS', params];
217220
case 'CalRGB':
218221
return 'DeviceRgbCS';
@@ -253,7 +256,10 @@ var ColorSpace = (function ColorSpaceClosure() {
253256
var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
254257
return ['AlternateCS', numComps, alt, tintFnIR];
255258
case 'Lab':
256-
var params = cs[1].getAll();
259+
var params = xref.fetchIfRef(cs[1]);
260+
if (isDict(params)) {
261+
params = params.getAll();
262+
}
257263
return ['LabCS', params];
258264
default:
259265
error('unimplemented color space object "' + mode + '"');

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"test:jest": "jest --config ./jest.config.json --detectOpenHandles",
3737
"test": "npm run test:jest && npm run parse-r && npm run parse-fd && npm run test:deno && npm run test:bun",
3838
"test:forms": "cd ./test && sh p2j.forms.sh",
39-
"test:misc": "cd ./test && sh p2j.one.sh misc . \"Expected: 15 success, 6 fail exception with stack trace\" ",
39+
"test:misc": "cd ./test && sh p2j.one.sh misc . \"Expected: 16 success, 6 fail exception with stack trace\" ",
4040
"parse": "./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form",
4141
"parse-s": "./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form -s",
4242
"parse-t": "./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form -s -t",
@@ -47,7 +47,7 @@
4747
"parse-tb": "./bin/pdf2json.js -f ./test/pdf/misc/i242_testingWithTable.pdf -o ./test/target/misc",
4848
"parse-tc": "./bin/pdf2json.js -f ./test/pdf/misc/i293_pdfpac.pdf -o ./test/target/misc",
4949
"parse-rectFix": "./bin/pdf2json.js -f ./test/pdf/misc/pr298_rect_fix_from_upstream.pdf -o ./test/target/misc",
50-
"parse-e": "./bin/pdf2json.js -f ./test/pdf/misc/i306_err_invalid.pdf -o ./test/target/misc",
50+
"parse-e": "./bin/pdf2json.js -f ./test/pdf/misc/i418_precompilato_fake.pdf -o ./test/target/misc",
5151
"build:rollup": "npx rollup -c ./rollup.config.js",
5252
"build:bundle-pdfjs-base": "node rollup/bundle-pdfjs-base.js",
5353
"build": "npm run build:bundle-pdfjs-base && npm run build:rollup",
@@ -68,8 +68,7 @@
6868
"bin": {
6969
"pdf2json": "bin/pdf2json.js"
7070
},
71-
"dependencies": {
72-
},
71+
"dependencies": {},
7372
"bundleDependencies": [],
7473
"devDependencies": {
7574
"@eslint/js": "^9.37.0",
@@ -122,4 +121,4 @@
122121
"readme.md",
123122
"license.txt"
124123
]
125-
}
124+
}
306 KB
Binary file not shown.

0 commit comments

Comments
 (0)