From dd198398b6e5c84ab1255a90ef96e6445b66a64f Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Fri, 3 Jan 2020 22:40:07 +0300 Subject: tdf#93389: keep encryption information for autorecovered MS formats The autorecovery data is stored in ODF, regardless of the original document format. When restoring, type detection generates ODF data, which is stored in the media descriptor attached to document, even after real filter was restored (see AutoRecovery::implts_openDocs). If real filter is not ODF, then at the save time, it doesn't find necessary information in encryption data, and makes not encrypted package. This patch adds both MS binary data, and OOXML data, to existing ODF data for recovered password-protected documents (regardless of their real filter). TODO: only add required information to encryption data: pass real filter name to DocPasswordHelper::requestAndVerifyDocPassword from AutoRecovery::implts_openDocs. Change-Id: I4749c5ec028ca61bddf7cd77bc5969a97b1de199 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86201 Reviewed-by: Mike Kaganski Tested-by: Mike Kaganski --- sfx2/source/appl/appopen.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'sfx2/source/appl/appopen.cxx') diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 66a3a26fc825..357e9e8033f4 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -234,6 +234,18 @@ ErrCode CheckPasswd_Impl if ( !aEncryptionData.hasElements() && aGpgProperties.hasElements() ) aEncryptionData = ::comphelper::DocPasswordHelper::decryptGpgSession(aGpgProperties); + // tdf#93389: if recoverying a document, encryption data should contain + // entries for the real filter, not only for recovery ODF, to keep it + // encrypted. Pass this in encryption data. + // TODO: pass here the real filter (from AutoRecovery::implts_openDocs) + // to marshal this to requestAndVerifyDocPassword + if (pSet->GetItemState(SID_DOC_SALVAGE, false) == SfxItemState::SET) + { + aEncryptionData = comphelper::concatSequences( + aEncryptionData, std::initializer_list{ + { "ForSalvage", css::uno::Any(true) } }); + } + SfxDocPasswordVerifier aVerifier( xStorage ); aEncryptionData = ::comphelper::DocPasswordHelper::requestAndVerifyDocPassword( aVerifier, aEncryptionData, aPassword, xInteractionHandler, pFile->GetOrigURL(), comphelper::DocPasswordRequestType::Standard ); -- cgit v1.2.3