Make get fingerprint
slightly more robust against corrupt PDF files
This patch adjusts `get fingerprint` to also check that the `/ID` entry contains (non-empty) strings, to prevent more possible failures when loading corrupt PDF files (follow-up to PR 5602). Note that I've not actually encountered such a PDF file in the wild. However given that `stringToBytes` will assert that the input is a string, and that we'll thus fail to load a document unless `get fingerprint` succeeds, making this more robust seems like a good idea to me.
This commit is contained in:
parent
3daae40425
commit
5853553455
@ -510,12 +510,11 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
return shadow(this, 'documentInfo', docInfo);
|
return shadow(this, 'documentInfo', docInfo);
|
||||||
},
|
},
|
||||||
get fingerprint() {
|
get fingerprint() {
|
||||||
var xref = this.xref, idArray, hash, fileID = '';
|
var xref = this.xref, hash, fileID = '';
|
||||||
|
var idArray = xref.trailer.get('ID');
|
||||||
|
|
||||||
if (xref.trailer.has('ID')) {
|
if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) &&
|
||||||
idArray = xref.trailer.get('ID');
|
idArray[0] !== EMPTY_FINGERPRINT) {
|
||||||
}
|
|
||||||
if (idArray && isArray(idArray) && idArray[0] !== EMPTY_FINGERPRINT) {
|
|
||||||
hash = stringToBytes(idArray[0]);
|
hash = stringToBytes(idArray[0]);
|
||||||
} else {
|
} else {
|
||||||
if (this.stream.ensureRange) {
|
if (this.stream.ensureRange) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user