mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Use Dict_getArray
in more places in src/core/
to avoid issues when Arrays contain indirect objects
As evident from e.g. PRs 6485 and 7118, some bad PDF generators unfortunately create Arrays where *some* elements are indirect objects (i.e. `Ref`s). This seems to mostly affect Arrays that contain numbers, such as e.g. `Matrix/FontMatrix/BBox/FontBBox/Rect/Color/...`, and has manifested itself in PDF files that fail to render correctly (some elements are missing). The problem in both the cases above, besides broken rendering, was that there were *no* errors/warnings that indicated what the problem was, making it difficult to pinpoint the issue. Hence this patch, where I've audited all usages of `Dict_get` in `src/core/` files, and replaced it with `Dict_getArray` where appropriate to try and prevent unnecessary future bugs.
This commit is contained in:
parent
8adddf031c
commit
6111c17c8a
8 changed files with 47 additions and 47 deletions
|
@ -144,8 +144,8 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||
}
|
||||
return out;
|
||||
}
|
||||
var domain = dict.get('Domain');
|
||||
var range = dict.get('Range');
|
||||
var domain = dict.getArray('Domain');
|
||||
var range = dict.getArray('Range');
|
||||
|
||||
if (!domain || !range) {
|
||||
error('No domain or range');
|
||||
|
@ -166,7 +166,7 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||
info('No support for cubic spline interpolation: ' + order);
|
||||
}
|
||||
|
||||
var encode = dict.get('Encode');
|
||||
var encode = dict.getArray('Encode');
|
||||
if (!encode) {
|
||||
encode = [];
|
||||
for (var i = 0; i < inputSize; ++i) {
|
||||
|
@ -176,7 +176,7 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||
}
|
||||
encode = toMultiArray(encode);
|
||||
|
||||
var decode = dict.get('Decode');
|
||||
var decode = dict.getArray('Decode');
|
||||
if (!decode) {
|
||||
decode = range;
|
||||
} else {
|
||||
|
@ -278,8 +278,8 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||
|
||||
constructInterpolated: function PDFFunction_constructInterpolated(str,
|
||||
dict) {
|
||||
var c0 = dict.get('C0') || [0];
|
||||
var c1 = dict.get('C1') || [1];
|
||||
var c0 = dict.getArray('C0') || [0];
|
||||
var c1 = dict.getArray('C1') || [1];
|
||||
var n = dict.get('N');
|
||||
|
||||
if (!isArray(c0) || !isArray(c1)) {
|
||||
|
@ -314,7 +314,7 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||
},
|
||||
|
||||
constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
|
||||
var domain = dict.get('Domain');
|
||||
var domain = dict.getArray('Domain');
|
||||
|
||||
if (!domain) {
|
||||
error('No domain');
|
||||
|
@ -331,8 +331,8 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||
fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
|
||||
}
|
||||
|
||||
var bounds = dict.get('Bounds');
|
||||
var encode = dict.get('Encode');
|
||||
var bounds = dict.getArray('Bounds');
|
||||
var encode = dict.getArray('Encode');
|
||||
|
||||
return [CONSTRUCT_STICHED, domain, bounds, encode, fns];
|
||||
},
|
||||
|
@ -394,8 +394,8 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||
|
||||
constructPostScript: function PDFFunction_constructPostScript(fn, dict,
|
||||
xref) {
|
||||
var domain = dict.get('Domain');
|
||||
var range = dict.get('Range');
|
||||
var domain = dict.getArray('Domain');
|
||||
var range = dict.getArray('Range');
|
||||
|
||||
if (!domain) {
|
||||
error('No domain.');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue