1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58: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:
Jonas Jenwald 2016-05-05 19:16:35 +02:00
parent 8adddf031c
commit 6111c17c8a
8 changed files with 47 additions and 47 deletions

View file

@ -110,7 +110,7 @@ Shadings.SMALL_NUMBER = 1e-6;
Shadings.RadialAxial = (function RadialAxialClosure() {
function RadialAxial(dict, matrix, xref, res) {
this.matrix = matrix;
this.coordsArr = dict.get('Coords');
this.coordsArr = dict.getArray('Coords');
this.shadingType = dict.get('ShadingType');
this.type = 'Pattern';
var cs = dict.get('ColorSpace', 'CS');
@ -119,14 +119,14 @@ Shadings.RadialAxial = (function RadialAxialClosure() {
var t0 = 0.0, t1 = 1.0;
if (dict.has('Domain')) {
var domainArr = dict.get('Domain');
var domainArr = dict.getArray('Domain');
t0 = domainArr[0];
t1 = domainArr[1];
}
var extendStart = false, extendEnd = false;
if (dict.has('Extend')) {
var extendArr = dict.get('Extend');
var extendArr = dict.getArray('Extend');
extendStart = extendArr[0];
extendEnd = extendArr[1];
}
@ -731,7 +731,7 @@ Shadings.Mesh = (function MeshClosure() {
this.matrix = matrix;
this.shadingType = dict.get('ShadingType');
this.type = 'Pattern';
this.bbox = dict.get('BBox');
this.bbox = dict.getArray('BBox');
var cs = dict.get('ColorSpace', 'CS');
cs = ColorSpace.parse(cs, xref, res);
this.cs = cs;
@ -749,7 +749,7 @@ Shadings.Mesh = (function MeshClosure() {
bitsPerCoordinate: dict.get('BitsPerCoordinate'),
bitsPerComponent: dict.get('BitsPerComponent'),
bitsPerFlag: dict.get('BitsPerFlag'),
decode: dict.get('Decode'),
decode: dict.getArray('Decode'),
colorFn: fn,
colorSpace: cs,
numComps: fn ? 1 : cs.numComps
@ -816,8 +816,8 @@ Shadings.Dummy = (function DummyClosure() {
})();
function getTilingPatternIR(operatorList, dict, args) {
var matrix = dict.get('Matrix');
var bbox = dict.get('BBox');
var matrix = dict.getArray('Matrix');
var bbox = dict.getArray('BBox');
var xstep = dict.get('XStep');
var ystep = dict.get('YStep');
var paintType = dict.get('PaintType');