mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Always prefer abbreviated keys, over full ones, when doing any dictionary lookups (issue 14256)
Note that issue 14256 was specifically about *inline* images, please refer to: - https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G7.1852045 - https://www.pdfa.org/safedocs-unearths-pdf-inline-image-issue/ - https://pdf-issues.pdfa.org/32000-2-2020/clause08.html#H8.9.7 However, during review of the initial PR in https://github.com/mozilla/pdf.js/pull/14257#issuecomment-964469710, it was suggested that we instead do this *unconditionally for all* dictionary lookups. In addition to re-ordering the existing call-sites in the `src/core`-code, and adding non-PRODUCTION/TESTING asserts to catch future errors, for consistency a number of existing `if`/`switch`-blocks were re-factored to also check the abbreviated keys first.
This commit is contained in:
parent
4ee906adf4
commit
ea1c348c67
12 changed files with 730 additions and 104 deletions
|
@ -580,8 +580,8 @@ class PartialEvaluator {
|
|||
}) {
|
||||
const dict = image.dict;
|
||||
const imageRef = dict.objId;
|
||||
const w = dict.get("Width", "W");
|
||||
const h = dict.get("Height", "H");
|
||||
const w = dict.get("W", "Width");
|
||||
const h = dict.get("H", "Height");
|
||||
|
||||
if (!(w && isNum(w)) || !(h && isNum(h))) {
|
||||
warn("Image dimensions are missing, or not numbers.");
|
||||
|
@ -604,8 +604,8 @@ class PartialEvaluator {
|
|||
operatorList.addOp(OPS.beginMarkedContentProps, ["OC", optionalContent]);
|
||||
}
|
||||
|
||||
const imageMask = dict.get("ImageMask", "IM") || false;
|
||||
const interpolate = dict.get("Interpolate", "I");
|
||||
const imageMask = dict.get("IM", "ImageMask") || false;
|
||||
const interpolate = dict.get("I", "Interpolate");
|
||||
let imgData, args;
|
||||
if (imageMask) {
|
||||
// This depends on a tmpCanvas being filled with the
|
||||
|
@ -613,20 +613,17 @@ class PartialEvaluator {
|
|||
// data can't be done here. Instead of creating a
|
||||
// complete PDFImage, only read the information needed
|
||||
// for later.
|
||||
|
||||
const width = dict.get("Width", "W");
|
||||
const height = dict.get("Height", "H");
|
||||
const bitStrideLength = (width + 7) >> 3;
|
||||
const bitStrideLength = (w + 7) >> 3;
|
||||
const imgArray = image.getBytes(
|
||||
bitStrideLength * height,
|
||||
bitStrideLength * h,
|
||||
/* forceClamped = */ true
|
||||
);
|
||||
const decode = dict.getArray("Decode", "D");
|
||||
const decode = dict.getArray("D", "Decode");
|
||||
|
||||
imgData = PDFImage.createMask({
|
||||
imgArray,
|
||||
width,
|
||||
height,
|
||||
width: w,
|
||||
height: h,
|
||||
imageIsFromDecodeStream: image instanceof DecodeStream,
|
||||
inverseDecode: !!decode && decode[0] > 0,
|
||||
interpolate,
|
||||
|
@ -648,7 +645,7 @@ class PartialEvaluator {
|
|||
return;
|
||||
}
|
||||
|
||||
const softMask = dict.get("SMask", "SM") || false;
|
||||
const softMask = dict.get("SM", "SMask") || false;
|
||||
const mask = dict.get("Mask") || false;
|
||||
|
||||
const SMALL_IMAGE_DIMENSIONS = 200;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue