From 86fadc484e3478de0c0f81ba1cab6cfbac39f5f7 Mon Sep 17 00:00:00 2001 From: Jakub Kucharski Date: Sun, 24 Jul 2016 22:46:23 +0200 Subject: [PATCH 2/2] treat file identifier as a hex string, not a basic string --- poppler/PDFDoc.cc | 12 ++++++------ poppler/PSOutputDev.cc | 5 +++-- poppler/SecurityHandler.cc | 3 ++- poppler/StructElement.cc | 5 +++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index f49e45a..296ed1a 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -696,8 +696,8 @@ GBool PDFDoc::getID(GooString *permanent_id, GooString *update_id) { Object obj2; if (permanent_id) { - if (obj.arrayGet(0, &obj2)->isString()) { - if (!get_id (obj2.getString(), permanent_id)) { + if (obj.arrayGet(0, &obj2)->isHexString()) { + if (!get_id (obj2.getHexString(), permanent_id)) { obj2.free(); return gFalse; } @@ -710,8 +710,8 @@ GBool PDFDoc::getID(GooString *permanent_id, GooString *update_id) { } if (update_id) { - if (obj.arrayGet(1, &obj2)->isString()) { - if (!get_id (obj2.getString(), update_id)) { + if (obj.arrayGet(1, &obj2)->isHexString()) { + if (!get_id (obj2.getHexString(), update_id)) { obj2.free(); return gFalse; } @@ -1458,7 +1458,7 @@ Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Goffset startxR //calculate md5 digest Guchar digest[16]; md5((Guchar*)message.getCString(), message.getLength(), digest); - obj1.initString(new GooString((const char*)digest, 16)); + obj1.initHexString(new GooString((const char*)digest, 16)); //create ID array Object obj2,obj3,obj5; @@ -1483,7 +1483,7 @@ Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Goffset startxR } else { //new file => same values for the two identifiers obj2.arrayAdd(&obj1); - obj1.initString(new GooString((const char*)digest, 16)); + obj1.initHexString(new GooString((const char*)digest, 16)); obj2.arrayAdd(&obj1); trailerDict->set("ID", &obj2); } diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index 204f16e..71715dd 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -30,6 +30,7 @@ // Copyright (C) 2012 Lu Wang // Copyright (C) 2014 Till Kamppeter // Copyright (C) 2015 Marek Kasik +// Copyright (C) 2016 Jakub Kucharski // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -7094,8 +7095,8 @@ void PSOutputDev::opiBegin13(GfxState *state, Dict *dict) { obj1.free(); dict->lookup("ID", &obj1); - if (obj1.isString()) { - writePSFmt("%ALDImageID: {0:t}\n", obj1.getString()); + if (obj1.isHexString()) { + writePSFmt("%ALDImageID: {0:t}\n", obj1.getHexString()); } obj1.free(); diff --git a/poppler/SecurityHandler.cc b/poppler/SecurityHandler.cc index 9e0546e..6d014ba 100644 --- a/poppler/SecurityHandler.cc +++ b/poppler/SecurityHandler.cc @@ -17,6 +17,7 @@ // Copyright (C) 2013 Adrian Johnson // Copyright (C) 2014 Fabio D'Urso // Copyright (C) 2016 Alok Anand +// Copyright (C) 2016 Jakub Kucharski // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -275,7 +276,7 @@ StandardSecurityHandler::StandardSecurityHandler(PDFDoc *docA, encRevision >= 2 && encRevision <= 3) { if (fileIDObj.isArray()) { if (fileIDObj.arrayGet(0, &fileIDObj1)->isString()) { - fileID = fileIDObj1.getString()->copy(); + fileID = fileIDObj1.getHexString()->copy(); } else { fileID = new GooString(); } diff --git a/poppler/StructElement.cc b/poppler/StructElement.cc index c668820..4285756 100644 --- a/poppler/StructElement.cc +++ b/poppler/StructElement.cc @@ -8,6 +8,7 @@ // Copyright 2014 Luigi Scarso // Copyright 2014 Albert Astals Cid // Copyright 2015 Dmytro Morgun +// Copyright 2016 Jakub Kucharski // //======================================================================== @@ -1122,8 +1123,8 @@ void StructElement::parse(Dict *element) obj.free(); // Object ID (optional), to be looked at the IDTree in the tree root. - if (element->lookup("ID", &obj)->isString()) { - s->id = obj.takeString(); + if (element->lookup("ID", &obj)->isHexString()) { + s->id = obj.takeHexString(); } obj.free(); -- 2.9.0