From 648990692c8253e3843c4c5954940e8b893d5f3e Mon Sep 17 00:00:00 2001 From: Franklin Weng Date: Sun, 18 Aug 2019 21:30:05 +0800 Subject: tdf#116862 do not encrypt to self when encryption key is not set When "always encrypt to self" is checked but no encryption key is set, encrypting a file with GPG key would cause error. So check if msPreferredKey is empty or not before comparing with sIssuer. Change-Id: I4d95f0b436cb1fafad1d57d50330fd2080902b69 Reviewed-on: https://gerrit.libreoffice.org/77665 Tested-by: Jenkins Reviewed-by: Katarina Behrens --- xmlsecurity/source/dialogs/certificatechooser.cxx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx b/xmlsecurity/source/dialogs/certificatechooser.cxx index 32c688f2a257..795e9bf3ae07 100644 --- a/xmlsecurity/source/dialogs/certificatechooser.cxx +++ b/xmlsecurity/source/dialogs/certificatechooser.cxx @@ -220,13 +220,15 @@ void CertificateChooser::ImplInitialize() #if HAVE_FEATURE_GPGME // only GPG has preferred keys - if ( sIssuer == msPreferredKey ) - { - if ( meAction == UserAction::Sign || meAction == UserAction::SelectSign ) - m_xCertLB->select(nRow); - else if ( meAction == UserAction::Encrypt && - aUserOpts.GetEncryptToSelf() ) - mxEncryptToSelf = xCert; + if ( !sIssuer.isEmpty() && !msPreferredKey.isEmpty() ) { + if ( sIssuer == msPreferredKey ) + { + if ( meAction == UserAction::Sign || meAction == UserAction::SelectSign ) + m_xCertLB->select(nRow); + else if ( meAction == UserAction::Encrypt && + aUserOpts.GetEncryptToSelf() ) + mxEncryptToSelf = xCert; + } } #endif } -- cgit