include/oox/helper/zipstorage.hxx | 2 +- oox/source/core/filterdetect.cxx | 11 ++++++----- oox/source/core/xmlfilterbase.cxx | 4 +++- oox/source/dump/pptxdumper.cxx | 2 +- package/source/xstor/xstorage.cxx | 6 ++++++ package/source/xstor/xstorage.hxx | 1 + 6 files changed, 18 insertions(+), 8 deletions(-)
New commits: commit 54d0f21a3f31cb8a16d6c250d8943d3824ff1848 Author: Mike Kaganski <[email protected]> AuthorDate: Thu Dec 14 12:56:03 2023 +0300 Commit: Xisco Fauli <[email protected]> CommitDate: Wed Dec 20 09:37:01 2023 +0100 tdf#131575: in repair mode, match names ASCII case-insensitively It would work for the bugdoc in tdf#131575; but not if the wrong case is the only problem in the package, because then there would be no repairment mode active. An alternative could be to use case insensitive match always, but that looks wrong. Change-Id: Ie405d37e1dc639482bd2608e4479de5b707a07d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160761 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160783 diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index 05150a48f988..d19d1cac7f33 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -403,6 +403,8 @@ void OStorage_Impl::OpenOwnPackage() aArguments.realloc( ++nArgNum ); pArguments = aArguments.getArray(); pArguments[nArgNum-1] <<= aNamedValue; + if (rProp.Name == "RepairPackage") + rProp.Value >>= m_bRepairPackage; } else if ( rProp.Name == "Password" ) { @@ -1264,6 +1266,10 @@ SotElement_Impl* OStorage_Impl::FindElement( const OUString& rName ) ReadContents(); auto mapIt = m_aChildrenMap.find(rName); + if (mapIt == m_aChildrenMap.end() && m_bRepairPackage) + mapIt = std::find_if(m_aChildrenMap.begin(), m_aChildrenMap.end(), + [&rName](const auto& pair) + { return rName.equalsIgnoreAsciiCase(pair.first); }); if (mapIt == m_aChildrenMap.end()) return nullptr; for (auto pElement : mapIt->second) diff --git a/package/source/xstor/xstorage.hxx b/package/source/xstor/xstorage.hxx index a32aeca1d25d..54fe49a9d9ca 100644 --- a/package/source/xstor/xstorage.hxx +++ b/package/source/xstor/xstorage.hxx @@ -122,6 +122,7 @@ struct OStorage_Impl bool m_bIsRoot; // marks this storage as root storages that manages all commits and reverts bool m_bListCreated; + bool m_bRepairPackage = false; /// Count of registered modification listeners oslInterlockedCount m_nModifiedListenerCount; commit 6ef97ac2bc1fb335943112374cf66103a4610cc3 Author: Mike Kaganski <[email protected]> AuthorDate: Thu Dec 14 12:54:15 2023 +0300 Commit: Xisco Fauli <[email protected]> CommitDate: Wed Dec 20 09:36:55 2023 +0100 Related: tdf#76115 Also pass RepairPackage to FilterDetect And drop the default argument value from ZipStorage ctor. Always pass it explicitly. Change-Id: I8bcf78dc4db7763567f9d6873841d75c328ede7e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160760 Tested-by: Mike Kaganski <[email protected]> Reviewed-by: Mike Kaganski <[email protected]> Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160782 Tested-by: Jenkins diff --git a/include/oox/helper/zipstorage.hxx b/include/oox/helper/zipstorage.hxx index dabb714d7db8..dd56a1f75a71 100644 --- a/include/oox/helper/zipstorage.hxx +++ b/include/oox/helper/zipstorage.hxx @@ -44,7 +44,7 @@ public: explicit ZipStorage( const css::uno::Reference< css::uno::XComponentContext >& rxContext, const css::uno::Reference< css::io::XInputStream >& rxInStream, - bool bRepairStorage = false ); + bool bRepairStorage ); explicit ZipStorage( const css::uno::Reference< css::uno::XComponentContext >& rxContext, diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx index cbee8cf1d933..6eab25684435 100644 --- a/oox/source/core/filterdetect.cxx +++ b/oox/source/core/filterdetect.cxx @@ -269,9 +269,9 @@ FilterDetect::~FilterDetect() namespace { -bool lclIsZipPackage( const Reference< XComponentContext >& rxContext, const Reference< XInputStream >& rxInStrm ) +bool lclIsZipPackage( const Reference< XComponentContext >& rxContext, const Reference< XInputStream >& rxInStrm, bool bRepairPackage ) { - ZipStorage aZipStorage( rxContext, rxInStrm ); + ZipStorage aZipStorage(rxContext, rxInStrm, bRepairPackage); return aZipStorage.isStorage(); } @@ -316,9 +316,10 @@ comphelper::DocPasswordVerifierResult PasswordVerifier::verifyEncryptionData( co Reference< XInputStream > FilterDetect::extractUnencryptedPackage( MediaDescriptor& rMediaDescriptor ) const { + const bool bRepairPackage(rMediaDescriptor.getUnpackedValueOrDefault("RepairPackage", false)); // try the plain input stream Reference<XInputStream> xInputStream( rMediaDescriptor[ MediaDescriptor::PROP_INPUTSTREAM ], UNO_QUERY ); - if( !xInputStream.is() || lclIsZipPackage( mxContext, xInputStream ) ) + if (!xInputStream.is() || lclIsZipPackage(mxContext, xInputStream, bRepairPackage)) return xInputStream; // check if a temporary file is passed in the 'ComponentData' property @@ -326,7 +327,7 @@ Reference< XInputStream > FilterDetect::extractUnencryptedPackage( MediaDescript if( xDecrypted.is() ) { Reference<XInputStream> xDecryptedInputStream = xDecrypted->getInputStream(); - if( lclIsZipPackage( mxContext, xDecryptedInputStream ) ) + if (lclIsZipPackage(mxContext, xDecryptedInputStream, bRepairPackage)) return xDecryptedInputStream; } @@ -380,7 +381,7 @@ Reference< XInputStream > FilterDetect::extractUnencryptedPackage( MediaDescript rMediaDescriptor.setComponentDataEntry( "DecryptedPackage", Any( xTempStream ) ); Reference<XInputStream> xDecryptedInputStream = xTempStream->getInputStream(); - if( lclIsZipPackage( mxContext, xDecryptedInputStream ) ) + if (lclIsZipPackage(mxContext, xDecryptedInputStream, bRepairPackage)) return xDecryptedInputStream; } } diff --git a/oox/source/dump/pptxdumper.cxx b/oox/source/dump/pptxdumper.cxx index c65b792063b2..5a386359d477 100644 --- a/oox/source/dump/pptxdumper.cxx +++ b/oox/source/dump/pptxdumper.cxx @@ -113,7 +113,7 @@ Dumper::Dumper( const Reference< XComponentContext >& rxContext, const Reference { if( rxContext.is() && rxInStrm.is() ) { - StorageRef xStrg = std::make_shared<ZipStorage>( rxContext, rxInStrm ); + StorageRef xStrg = std::make_shared<ZipStorage>( rxContext, rxInStrm, false ); ConfigRef xCfg = std::make_shared<Config>( DUMP_PPTX_CONFIG_ENVVAR, rxContext, xStrg, rSysFileName ); DumperBase::construct( xCfg ); } commit 8e393c141487acc0460037dbe5af1793d3663aef Author: Mike Kaganski <[email protected]> AuthorDate: Thu Dec 14 11:51:42 2023 +0300 Commit: Xisco Fauli <[email protected]> CommitDate: Wed Dec 20 09:36:48 2023 +0100 tdf#76115: pass RepairPackage property from media descriptor to ZipStorage See commit 86c682273d907c77404637c89e584047de1c1099. Change-Id: I51a3beb00f635554ac73cc9ea957e18fb8e84349 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160757 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160781 diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 93b5816812a1..2c0cfa9732eb 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -1014,7 +1014,9 @@ bool XmlFilterBase::implFinalizeExport( MediaDescriptor& rMediaDescriptor ) StorageRef XmlFilterBase::implCreateStorage( const Reference< XInputStream >& rxInStream ) const { - return std::make_shared<ZipStorage>( getComponentContext(), rxInStream ); + return std::make_shared<ZipStorage>( + getComponentContext(), rxInStream, + getMediaDescriptor().getUnpackedValueOrDefault("RepairPackage", false)); } StorageRef XmlFilterBase::implCreateStorage( const Reference< XStream >& rxOutStream ) const
