mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Ensure that |get fingerprint| doesn't fail if the ID is not an array (issue 5599)
According to the [PDF specification](http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#page=51) the `ID` should be an array. To prevent errors if the PDF file violates that part of the spec, check that the `ID` is actually an array. Fixes 5599.
This commit is contained in:
parent
6e66e30d92
commit
1fea44ce14
4 changed files with 91 additions and 5 deletions
|
@ -281,9 +281,9 @@ var Page = (function PageClosure() {
|
|||
*/
|
||||
var PDFDocument = (function PDFDocumentClosure() {
|
||||
var FINGERPRINT_FIRST_BYTES = 1024;
|
||||
|
||||
var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' +
|
||||
'\x00\x00\x00\x00\x00\x00\x00\x00\x00';
|
||||
|
||||
function PDFDocument(pdfManager, arg, password) {
|
||||
if (isStream(arg)) {
|
||||
init.call(this, pdfManager, arg, password);
|
||||
|
@ -495,11 +495,13 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||
return shadow(this, 'documentInfo', docInfo);
|
||||
},
|
||||
get fingerprint() {
|
||||
var xref = this.xref, hash, fileID = '';
|
||||
var xref = this.xref, idArray, hash, fileID = '';
|
||||
|
||||
if (xref.trailer.has('ID') &&
|
||||
xref.trailer.get('ID')[0] !== EMPTY_FINGERPRINT) {
|
||||
hash = stringToBytes(xref.trailer.get('ID')[0]);
|
||||
if (xref.trailer.has('ID')) {
|
||||
idArray = xref.trailer.get('ID');
|
||||
}
|
||||
if (idArray && isArray(idArray) && idArray[0] !== EMPTY_FINGERPRINT) {
|
||||
hash = stringToBytes(idArray[0]);
|
||||
} else {
|
||||
if (this.stream.ensureRange) {
|
||||
this.stream.ensureRange(0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue