[poppler] poppler/Form.cc poppler/Form.h qt5/src qt6/src
poppler/Form.cc |1 + poppler/Form.h |1 + qt5/src/poppler-form.cc |1 + qt6/src/poppler-form.cc |1 + 4 files changed, 4 insertions(+) New commits: commit 368465a8ce191a5756abae90d49ca861fae104e7 Author: Albert Astals Cid Date: Fri Apr 15 10:43:31 2022 +0200 Update (C) diff --git a/poppler/Form.cc b/poppler/Form.cc index 486a9b4e..5ee1e221 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc @@ -33,6 +33,7 @@ // Copyright 2021 Georgiy Sgibnev . Work sponsored by lab50.net. // Copyright 2021 Theofilos Intzoglou // Copyright 2021 Even Rouault +// Copyright 2022 Alexander Sulfrian // // diff --git a/poppler/Form.h b/poppler/Form.h index 1157147b..9017bd42 100644 --- a/poppler/Form.h +++ b/poppler/Form.h @@ -26,6 +26,7 @@ // Copyright 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by Technische Universität Dresden // Copyright 2021 Georgiy Sgibnev . Work sponsored by lab50.net. // Copyright 2021 Theofilos Intzoglou +// Copyright 2022 Alexander Sulfrian // // diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc index 1144c174..a6d40910 100644 --- a/qt5/src/poppler-form.cc +++ b/qt5/src/poppler-form.cc @@ -15,6 +15,7 @@ * Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by Technische Universität Dresden * Copyright (C) 2021 Georgiy Sgibnev . Work sponsored by lab50.net. * Copyright (C) 2021 Theofilos Intzoglou + * Copyright (C) 2022 Alexander Sulfrian * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/qt6/src/poppler-form.cc b/qt6/src/poppler-form.cc index e97b327b..c06eb9ae 100644 --- a/qt6/src/poppler-form.cc +++ b/qt6/src/poppler-form.cc @@ -15,6 +15,7 @@ * Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, . Work sponsored by Technische Universität Dresden * Copyright (C) 2021 Georgiy Sgibnev . Work sponsored by lab50.net. * Copyright (C) 2021 Theofilos Intzoglou + * Copyright (C) 2022 Alexander Sulfrian * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
[poppler] poppler/Form.cc poppler/Form.h qt5/src qt6/src
poppler/Form.cc |3 ++- poppler/Form.h |2 +- qt5/src/poppler-form.cc |5 +++-- qt6/src/poppler-form.cc |5 +++-- 4 files changed, 9 insertions(+), 6 deletions(-) New commits: commit 10d74ff226b8b7e930a75b050664272df30c2aba Author: Alexander Sulfrian Date: Thu Apr 14 00:43:58 2022 +0200 qt: Pass leftFontSize down to `FormWidgetSignature::signDocumentWithAppearence` A similar issue for `PDFDoc::sign` was already fixed in: 864466a6753014106448f1a6caa68bedf101 diff --git a/poppler/Form.cc b/poppler/Form.cc index 0aafd912..486a9b4e 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc @@ -687,7 +687,7 @@ bool FormWidgetSignature::signDocument(const char *saveFilename, const char *cer bool FormWidgetSignature::signDocumentWithAppearance(const char *saveFilename, const char *certNickname, const char *digestName, const char *password, const GooString *reason, const GooString *location, const std::optional , const std::optional , const GooString , const GooString , double fontSize, - std::unique_ptr &, double borderWidth, std::unique_ptr &, std::unique_ptr &) + double leftFontSize, std::unique_ptr &, double borderWidth, std::unique_ptr &, std::unique_ptr &) { // Set the appearance GooString *aux = getField()->getDefaultAppearance(); @@ -722,6 +722,7 @@ bool FormWidgetSignature::signDocumentWithAppearance(const char *saveFilename, c ::FormFieldSignature *ffs = static_cast<::FormFieldSignature *>(getField()); ffs->setCustomAppearanceContent(signatureText); ffs->setCustomAppearanceLeftContent(signatureTextLeft); +ffs->setCustomAppearanceLeftFontSize(leftFontSize); const bool success = signDocument(saveFilename, certNickname, digestName, password, reason, location, ownerPassword, userPassword); diff --git a/poppler/Form.h b/poppler/Form.h index 903482a0..1157147b 100644 --- a/poppler/Form.h +++ b/poppler/Form.h @@ -312,7 +312,7 @@ public: // Same as above but adds text, font color, etc. bool signDocumentWithAppearance(const char *filename, const char *certNickname, const char *digestName, const char *password, const GooString *reason = nullptr, const GooString *location = nullptr, const std::optional = {}, const std::optional = {}, const GooString = {}, const GooString = {}, double fontSize = {}, -std::unique_ptr & = {}, double borderWidth = {}, std::unique_ptr & = {}, std::unique_ptr & = {}); +double leftFontSize = {}, std::unique_ptr & = {}, double borderWidth = {}, std::unique_ptr & = {}, std::unique_ptr & = {}); // checks the length encoding of the signature and returns the hex encoded signature // if the check passed (and the checked file size as output parameter in checkedFileSize) diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc index 665fb5f4..1144c174 100644 --- a/qt5/src/poppler-form.cc +++ b/qt5/src/poppler-form.cc @@ -1102,8 +1102,9 @@ FormFieldSignature::SigningResult FormFieldSignature::sign(const QString const auto gSignatureText = std::unique_ptr(QStringToUnicodeGooString(data.signatureText())); const auto gSignatureLeftText = std::unique_ptr(QStringToUnicodeGooString(data.signatureLeftText())); -const bool success = fws->signDocumentWithAppearance(outputFileName.toUtf8().constData(), data.certNickname().toUtf8().constData(), "SHA256", data.password().toUtf8().constData(), reason.get(), location.get(), ownerPwd, userPwd, - *gSignatureText, *gSignatureLeftText, data.fontSize(), convertQColor(data.fontColor()), data.borderWidth(), convertQColor(data.borderColor()), convertQColor(data.backgroundColor())); +const bool success = + fws->signDocumentWithAppearance(outputFileName.toUtf8().constData(), data.certNickname().toUtf8().constData(), "SHA256", data.password().toUtf8().constData(), reason.get(), location.get(), ownerPwd, userPwd, *gSignatureText, +*gSignatureLeftText, data.fontSize(), data.leftFontSize(), convertQColor(data.fontColor()), data.borderWidth(), convertQColor(data.borderColor()), convertQColor(data.backgroundColor())); return success ? SigningSuccess : GenericSigningError; } diff --git a/qt6/src/poppler-form.cc b/qt6/src/poppler-form.cc index 7e963f0f..e97b327b 100644 --- a/qt6/src/poppler-form.cc +++ b/qt6/src/poppler-form.cc @@ -1102,8 +1102,9 @@ FormFieldSignature::SigningResult FormFieldSignature::sign(const QString const auto gSignatureText = std::unique_ptr(QStringToUnicodeGooString(data.signatureText())); const auto gSignatureLeftText =
[poppler] poppler/Form.cc poppler/Form.h qt5/src qt6/src utils/pdfsig.cc
poppler/Form.cc | 12 ++-- poppler/Form.h |7 --- qt5/src/poppler-form.cc |5 ++--- qt6/src/poppler-form.cc |5 ++--- utils/pdfsig.cc |6 ++ 5 files changed, 16 insertions(+), 19 deletions(-) New commits: commit 5f52816b85c82eb41fdd4f4bf4020f8a679e931d Author: Albert Astals Cid Date: Mon Jan 3 14:51:10 2022 +0100 Make FormFieldSignature::getCheckedSignature return an optional diff --git a/poppler/Form.cc b/poppler/Form.cc index f42801b4..f2b4815a 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc @@ -5,7 +5,7 @@ // This file is licensed under the GPLv2 or later // // Copyright 2006-2008 Julien Rebetez -// Copyright 2007-2012, 2015-2021 Albert Astals Cid +// Copyright 2007-2012, 2015-2022 Albert Astals Cid // Copyright 2007-2008, 2011 Carlos Garcia Campos // Copyright 2007, 2013, 2016, 2019 Adrian Johnson // Copyright 2007 Iñigo Martínez @@ -815,7 +815,7 @@ std::vector FormWidgetSignature::getSignedRangeBounds() const return static_cast(field)->getSignedRangeBounds(); } -GooString *FormWidgetSignature::getCheckedSignature(Goffset *checkedFileSize) +std::optional FormWidgetSignature::getCheckedSignature(Goffset *checkedFileSize) { return static_cast(field)->getCheckedSignature(checkedFileSize); } @@ -2241,7 +2241,7 @@ std::vector FormFieldSignature::getSignedRangeBounds() const return range_vec; } -GooString *FormFieldSignature::getCheckedSignature(Goffset *checkedFileSize) +std::optional FormFieldSignature::getCheckedSignature(Goffset *checkedFileSize) { Goffset start = 0; Goffset end = 0; @@ -2274,7 +2274,7 @@ GooString *FormFieldSignature::getCheckedSignature(Goffset *checkedFileSize) do { c1 = stream->getChar(); if (c1 == EOF) -return nullptr; +return {}; gstr.append(static_cast(c1)); } while (++pos < len); if (gstr.getChar(0) == '3' && gstr.getChar(1) == '0') { @@ -2329,12 +2329,12 @@ GooString *FormFieldSignature::getCheckedSignature(Goffset *checkedFileSize) len = 0; } if (len > 0) { -return new GooString(, 0, len); +return GooString(, 0, len); } } } } -return nullptr; +return {}; } void FormFieldSignature::print(int indent) diff --git a/poppler/Form.h b/poppler/Form.h index 9f98c02e..a5ca8fdf 100644 --- a/poppler/Form.h +++ b/poppler/Form.h @@ -6,7 +6,7 @@ // // Copyright 2006 Julien Rebetez // Copyright 2007, 2008, 2011 Carlos Garcia Campos -// Copyright 2007-2010, 2012, 2015-2021 Albert Astals Cid +// Copyright 2007-2010, 2012, 2015-2022 Albert Astals Cid // Copyright 2010 Mark Riedesel // Copyright 2011 Pino Toscano // Copyright 2012 Fabio D'Urso @@ -38,6 +38,7 @@ #include +#include #include #include @@ -316,7 +317,7 @@ public: // checks the length encoding of the signature and returns the hex encoded signature // if the check passed (and the checked file size as output parameter in checkedFileSize) // otherwise a nullptr is returned -GooString *getCheckedSignature(Goffset *checkedFileSize); +std::optional getCheckedSignature(Goffset *checkedFileSize); const GooString *getSignature() const; @@ -607,7 +608,7 @@ public: // checks the length encoding of the signature and returns the hex encoded signature // if the check passed (and the checked file size as output parameter in checkedFileSize) // otherwise a nullptr is returned -GooString *getCheckedSignature(Goffset *checkedFileSize); +std::optional getCheckedSignature(Goffset *checkedFileSize); ~FormFieldSignature() override; Object *getByteRange() { return _range; } diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc index 43ce0546..36f7b451 100644 --- a/qt5/src/poppler-form.cc +++ b/qt5/src/poppler-form.cc @@ -1,6 +1,6 @@ /* poppler-form.h: qt interface to poppler * Copyright (C) 2007-2008, 2011, Pino Toscano - * Copyright (C) 2008, 2011, 2012, 2015-2021 Albert Astals Cid + * Copyright (C) 2008, 2011, 2012, 2015-2022 Albert Astals Cid * Copyright (C) 2011 Carlos Garcia Campos * Copyright (C) 2012, Adam Reichold * Copyright (C) 2016, Hanno Meyer-Thurow @@ -1049,11 +1049,10 @@ SignatureValidationInfo FormFieldSignature::validate(int opt, const QDateTime priv->range_bounds.append(bound); } } -GooString *checkedSignature = fws->getCheckedSignature(>docLength); +const std::optional checkedSignature = fws->getCheckedSignature(>docLength); if (priv->range_bounds.size() == 4 && checkedSignature) { priv->signature = QByteArray::fromHex(checkedSignature->c_str()); } -delete checkedSignature; return SignatureValidationInfo(priv); } diff --git a/qt6/src/poppler-form.cc
[poppler] poppler/Form.cc poppler/Form.h qt5/src qt6/src
poppler/Form.cc | 12 poppler/Form.h |2 ++ qt5/src/poppler-document.cc |2 +- qt6/src/poppler-document.cc |2 +- 4 files changed, 16 insertions(+), 2 deletions(-) New commits: commit 59d5036451cc55f57e15e4ae1538024c62452978 Author: Albert Astals Cid Date: Tue Mar 9 17:53:00 2021 +0100 qt: Fix crash in files with malformed signatures For signatures we need the formwidget, so even if they don't have the Subtype Widget create one when asked for signatures in the document Fixes KDE bug #433909 diff --git a/poppler/Form.cc b/poppler/Form.cc index 9937eefd..4d42aedf 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc @@ -1975,6 +1975,18 @@ void FormFieldSignature::setCertificateInfo(std::unique_ptr certificate_info.swap(certInfo); } +FormWidget *FormFieldSignature::getCreateWidget() +{ +::FormWidget *fw = getWidget(0); +if (!fw) { +error(errSyntaxError, 0, "FormFieldSignature: was asked for widget and didn't had one, creating it"); +_createWidget(, ref); +fw = getWidget(0); +fw->createWidgetAnnotation(); +} +return fw; +} + void FormFieldSignature::parseInfo() { if (!obj.isDict()) diff --git a/poppler/Form.h b/poppler/Form.h index dcf89760..247fc141 100644 --- a/poppler/Form.h +++ b/poppler/Form.h @@ -617,6 +617,8 @@ public: void setCertificateInfo(std::unique_ptr &); +FormWidget *getCreateWidget(); + private: void parseInfo(); void hashSignedDataBlock(SignatureHandler *handler, Goffset block_len); diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc index 0a2a6ce4..c7d38be2 100644 --- a/qt5/src/poppler-document.cc +++ b/qt5/src/poppler-document.cc @@ -825,7 +825,7 @@ QVector Document::signatures() const const std::vector<::FormFieldSignature *> pSignatures = m_doc->doc->getSignatureFields(); for (::FormFieldSignature *pSignature : pSignatures) { -::FormWidget *fw = pSignature->getWidget(0); +::FormWidget *fw = pSignature->getCreateWidget(); ::Page *p = m_doc->doc->getPage(fw->getWidgetAnnotation()->getPageNum()); result.append(new FormFieldSignature(m_doc, p, static_cast(fw))); } diff --git a/qt6/src/poppler-document.cc b/qt6/src/poppler-document.cc index 1a13d46d..150cca0a 100644 --- a/qt6/src/poppler-document.cc +++ b/qt6/src/poppler-document.cc @@ -807,7 +807,7 @@ QVector Document::signatures() const const std::vector<::FormFieldSignature *> pSignatures = m_doc->doc->getSignatureFields(); for (::FormFieldSignature *pSignature : pSignatures) { -::FormWidget *fw = pSignature->getWidget(0); +::FormWidget *fw = pSignature->getCreateWidget(); ::Page *p = m_doc->doc->getPage(fw->getWidgetAnnotation()->getPageNum()); result.append(new FormFieldSignature(m_doc, p, static_cast(fw))); } ___ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler