1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +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

@ -174,7 +174,7 @@ var Annotation = (function AnnotationClosure() {
this.setFlags(dict.get('F'));
this.setRectangle(dict.getArray('Rect'));
this.setColor(dict.get('C'));
this.setColor(dict.getArray('C'));
this.setBorderStyle(dict);
this.appearance = getDefaultAppearance(dict);
@ -325,10 +325,10 @@ var Annotation = (function AnnotationClosure() {
dictType.name === 'Border')) {
this.borderStyle.setWidth(dict.get('W'));
this.borderStyle.setStyle(dict.get('S'));
this.borderStyle.setDashArray(dict.get('D'));
this.borderStyle.setDashArray(dict.getArray('D'));
}
} else if (borderStyle.has('Border')) {
var array = borderStyle.get('Border');
var array = borderStyle.getArray('Border');
if (isArray(array) && array.length >= 3) {
this.borderStyle.setHorizontalCornerRadius(array[0]);
this.borderStyle.setVerticalCornerRadius(array[1]);
@ -400,8 +400,8 @@ var Annotation = (function AnnotationClosure() {
// ProcSet
// Properties
]);
var bbox = appearanceDict.get('BBox') || [0, 0, 1, 1];
var matrix = appearanceDict.get('Matrix') || [1, 0, 0, 1, 0 ,0];
var bbox = appearanceDict.getArray('BBox') || [0, 0, 1, 1];
var matrix = appearanceDict.getArray('Matrix') || [1, 0, 0, 1, 0 ,0];
var transform = getTransformMatrix(data.rect, bbox, matrix);
var self = this;
@ -820,7 +820,7 @@ var PopupAnnotation = (function PopupAnnotationClosure() {
// Fall back to the default background color.
this.data.color = null;
} else {
this.setColor(parentItem.get('C'));
this.setColor(parentItem.getArray('C'));
this.data.color = this.color;
}
}