/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
for (constauto& [rShortName, rInfo] : maContents)
{ if ( rInfo.bFolder )
{ if ( aPath == u"META-INF/" )
{ // META-INF is not allowed to contain subfolders
bHasUnexpected = true;
} elseif (isWholesomeEncryption && rShortName != u"META-INF")
{
bHasUnexpected = true;
} else
{
OUString sOwnPath = aPath + rShortName + "/";
bHasUnexpected = rInfo.pFolder->LookForUnexpectedODF12Streams(sOwnPath, isWholesomeEncryption);
}
} else
{ if ( aPath == u"META-INF/" )
{ if ( rShortName != "manifest.xml"
&& rShortName.indexOf( "signatures" ) == -1 )
{ // a stream from META-INF with unexpected name
bHasUnexpected = true;
}
// streams from META-INF with expected names are allowed not to be registered in manifest.xml
} elseif (isWholesomeEncryption && rShortName != "mimetype" && rShortName != "encrypted-package")
{
bHasUnexpected = true;
} elseif ( !rInfo.pStream->IsFromManifest() )
{ // the stream is not in META-INF and is not registered in manifest.xml, // check whether it is an internal part of the package format if ( !aPath.empty() || rShortName != "mimetype" )
{ // if it is not "mimetype" from the root it is not a part of the package
bHasUnexpected = true;
}
}
}
// folder can have a mediatype only in package format if ( aPropSet.hasElements() && ( m_nFormat == embed::StorageFormats::PACKAGE ) )
rManList.push_back( aPropSet );
returntrue;
}
void ZipPackageFolder::saveContents( const OUString &rPath,
std::vector < uno::Sequence < PropertyValue > > &rManList,
ZipOutputStream & rZipOut, const uno::Sequence < sal_Int8 >& rEncryptionKey,
::std::optional<sal_Int32> const oPBKDF2IterationCount,
::std::optional<::std::tuple<sal_Int32, sal_Int32, sal_Int32>> const oArgon2Args) const
{ if ( maContents.empty() && !rPath.isEmpty() && m_nFormat != embed::StorageFormats::OFOPXML )
{ // it is an empty subfolder, use workaround to store it auto pTempEntry = std::make_unique<ZipEntry>(aEntry);
pTempEntry->nPathLen = static_cast<sal_Int16>( OUStringToOString( rPath, RTL_TEXTENCODING_UTF8 ).getLength() );
pTempEntry->nExtraLen = -1;
pTempEntry->sPath = rPath;
bool bMimeTypeStreamStored = false;
OUString aMimeTypeStreamName(u"mimetype"_ustr); if ( m_nFormat == embed::StorageFormats::ZIP && rPath.isEmpty() )
{ // let the "mimetype" stream in root folder be stored as the first stream if it is zip format
ContentHash::const_iterator aIter = maContents.find ( aMimeTypeStreamName ); if ( aIter != maContents.end() && !(*aIter).second.bFolder )
{
bMimeTypeStreamStored = true; if (!aIter->second.pStream->saveChild(rPath + aIter->first, rManList, rZipOut,
rEncryptionKey, oPBKDF2IterationCount, oArgon2Args))
{ throw uno::RuntimeException( THROW_WHERE );
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.