diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-11-29 13:07:57 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-11-29 14:11:56 +0100 |
commit | 63634738dd03cc74806ce6843c16ff5e51a371a0 (patch) | |
tree | 67679b7c859ce769d907fd8543b765250d8aaa14 /sfx2 | |
parent | 88b0cb4c31d0631ff8db1e4842dc1431ae6d0234 (diff) |
tdf#118639: store ODF encryption data for autorecovery
When saving autorecovery information, ODF is used. If the original
document is password-protected, its autorecovery is also generated
password-protected (since ef87ff6680f79362a431db6e7ef2f40cfc576219).
But when the stored encryption data for non-ODF document does not
contain "PackageSHA256UTF8EncryptionKey" value, following
ZipPackage::GetEncryptionKey fails, so the whole save fails.
So just generate and append ODF encryption keys where we still have
user password.
Change-Id: I776e28de784489521e4941d1075690f90c056014
Reviewed-on: https://gerrit.libreoffice.org/84052
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/filedlghelper.cxx | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index c5a350afa608..9464aaaea2ef 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -2703,6 +2703,8 @@ ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, { if ( pPasswordRequest->getPassword().getLength() ) { + css::uno::Sequence< css::beans::NamedValue > aEncryptionData; + // TODO/LATER: The filters should show the password dialog themself in future if ( bMSType ) { @@ -2711,7 +2713,7 @@ ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, { ::comphelper::SequenceAsHashMap aHashData; aHashData[ OUString( "OOXPassword" ) ] <<= pPasswordRequest->getPassword(); - pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aHashData.getAsConstNamedValueList() ) ) ); + aEncryptionData = aHashData.getAsConstNamedValueList(); } else { @@ -2724,7 +2726,7 @@ ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, aHashData[ OUString( "STD97EncryptionKey" ) ] <<= aEncryptionKey; aHashData[ OUString( "STD97UniqueID" ) ] <<= aUniqueID; - pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aHashData.getAsConstNamedValueList() ) ) ); + aEncryptionData = aHashData.getAsConstNamedValueList(); } else { @@ -2732,10 +2734,14 @@ ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, } } } - else - { - pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( ::comphelper::OStorageHelper::CreatePackageEncryptionData( pPasswordRequest->getPassword() ) ) ) ); - } + + // tdf#118639: We need ODF encryption data for autorecovery where password will already + // be unavailable, even for non-ODF documents, so append it here unconditionally + pSet->Put(SfxUnoAnyItem( + SID_ENCRYPTIONDATA, + uno::makeAny(comphelper::concatSequences( + aEncryptionData, comphelper::OStorageHelper::CreatePackageEncryptionData( + pPasswordRequest->getPassword()))))); } if ( pPasswordRequest->getRecommendReadOnly() ) |