Merge pull request #6427 from Snuffleupagus/slightly-more-robust-get-fingerprint

Make `get fingerprint` slightly more robust against corrupt PDF files
This commit is contained in:
Tim van der Meij 2015-09-10 22:07:44 +02:00
commit 12b0b9744b

View File

@ -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) {