Skip to content

Commit

Permalink
Merge pull request #5602 from Snuffleupagus/issue-5599
Browse files Browse the repository at this point in the history
Ensure that |get fingerprint| doesn't fail if the ID is not an array (issue 5599)
  • Loading branch information
yurydelendik committed Dec 30, 2014
2 parents 6e66e30 + 1fea44c commit 55098bc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
!issue5291.pdf
!issue5421.pdf
!issue5470.pdf
!issue5599.pdf
!gradientfill.pdf
!bug903856.pdf
!bug850854.pdf
Expand Down
Binary file added test/pdfs/issue5599.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,13 @@
"lastPage": 1,
"type": "load"
},
{ "id": "issue5599",
"file": "pdfs/issue5599.pdf",
"md5": "529a4a9409ac024aeb57a047210280fe",
"rounds": 1,
"link": false,
"type": "load"
},
{ "id": "txt2pdf",
"file": "pdfs/txt2pdf.pdf",
"md5": "02cefa0f5e8d96313bb05163b2f88c8c",
Expand Down

0 comments on commit 55098bc

Please sign in to comment.