summaryrefslogtreecommitdiffstats
path: root/package/source/zippackage/ZipPackage.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'package/source/zippackage/ZipPackage.cxx')
-rw-r--r--package/source/zippackage/ZipPackage.cxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 02f7cf71e8..0f3fa6ff7d 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -171,6 +171,7 @@ void ZipPackage::parseManifest()
return;
bool bManifestParsed = false;
+ ::std::optional<OUString> oFirstVersion;
static constexpr OUString sMeta (u"META-INF"_ustr);
if ( m_xRootFolder->hasByName( sMeta ) )
{
@@ -216,7 +217,13 @@ void ZipPackage::parseManifest()
if ( rValue.Name == sPropFullPath )
rValue.Value >>= sPath;
else if ( rValue.Name == sPropVersion )
+ {
rValue.Value >>= sVersion;
+ if (!oFirstVersion)
+ {
+ oFirstVersion.emplace(sVersion);
+ }
+ }
else if ( rValue.Name == sPropMediaType )
rValue.Value >>= sMediaType;
else if ( rValue.Name == sPropSalt )
@@ -457,6 +464,11 @@ void ZipPackage::parseManifest()
{
// accept only types that look similar to own mediatypes
m_xRootFolder->SetMediaType( aPackageMediatype );
+ // also set version explicitly
+ if (oFirstVersion && m_xRootFolder->GetVersion().isEmpty())
+ {
+ m_xRootFolder->SetVersion(*oFirstVersion);
+ }
// if there is an encrypted inner package, there is no root
// document, because instead there is a package, and it is not
// an error
@@ -1716,6 +1728,11 @@ uno::Sequence< sal_Int8 > ZipPackage::GetEncryptionKey()
for ( const auto& rKey : std::as_const(m_aStorageEncryptionKeys) )
if ( rKey.Name == aNameToFind )
rKey.Value >>= aResult;
+
+ if (!aResult.hasElements() && m_aStorageEncryptionKeys.hasElements())
+ { // tdf#159519 sanity check
+ throw uno::RuntimeException(THROW_WHERE "Expected key is missing!");
+ }
}
else
aResult = m_aEncryptionKey;