package/inc/ZipFile.hxx | 13 +++++++------ package/source/zipapi/ZipFile.cxx | 25 ++++--------------------- package/source/zippackage/ZipPackage.cxx | 8 ++++++-- package/source/zippackage/zipfileaccess.cxx | 2 +- 4 files changed, 18 insertions(+), 30 deletions(-)
New commits: commit bf9ece7cf6d184675fac1eba88ebcb04bf81442f Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Wed Jul 17 12:04:13 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Jul 18 21:59:58 2024 +0200 package: don't check case insensitive duplicates for ZIP package Turns out there's a TexMaths extension that contains files with names differing only in case. https://ask.libreoffice.org/t/zipexception-when-installing-an-extension/108256 There isn't a separate ZipPackage mode for OXT so just don't check in the ZIP mode. Change-Id: I7680c93f5f24ac566a59b131b36d855bd85100b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170616 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 0fb25ce9ff9a3ede8d43ee1502c44b4c02135b3f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170623 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx index d9910fde92a9..7e7de4bd67bc 100644 --- a/package/inc/ZipFile.hxx +++ b/package/inc/ZipFile.hxx @@ -52,9 +52,14 @@ class ZipEnumeration; class ZipFile { +public: + enum class Checks { Default, CheckInsensitive }; + +private: rtl::Reference<comphelper::RefCountedMutex> m_aMutexHolder; std::unordered_set<OUString> m_EntriesInsensitive; + Checks m_Checks; EntryHash aEntries; ByteGrabber aGrabber; @@ -95,16 +100,12 @@ class ZipFile public: - ZipFile( rtl::Reference<comphelper::RefCountedMutex> aMutexHolder, - css::uno::Reference < css::io::XInputStream > const &xInput, - css::uno::Reference < css::uno::XComponentContext > xContext, - bool bInitialise ); - ZipFile( rtl::Reference<comphelper::RefCountedMutex> aMutexHolder, css::uno::Reference < css::io::XInputStream > const &xInput, css::uno::Reference < css::uno::XComponentContext > xContext, bool bInitialise, - bool bForceRecover ); + bool bForceRecover, + Checks checks); ~ZipFile(); diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index 1e1ab575dcfe..6773fcf20e1f 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -80,30 +80,13 @@ using ZipUtils::Inflater; /** This class is used to read entries from a zip file */ -ZipFile::ZipFile( rtl::Reference<comphelper::RefCountedMutex> aMutexHolder, - uno::Reference < XInputStream > const &xInput, - uno::Reference < XComponentContext > xContext, - bool bInitialise ) -: m_aMutexHolder(std::move( aMutexHolder )) -, aGrabber( xInput ) -, aInflater( true ) -, xStream(xInput) -, m_xContext (std::move( xContext )) -, bRecoveryMode( false ) -{ - if (bInitialise && readCEN() == -1 ) - { - aEntries.clear(); - m_EntriesInsensitive.clear(); - throw ZipException( "stream data looks to be broken" ); - } -} - ZipFile::ZipFile( rtl::Reference< comphelper::RefCountedMutex > aMutexHolder, uno::Reference < XInputStream > const &xInput, uno::Reference < XComponentContext > xContext, - bool bInitialise, bool bForceRecovery) + bool bInitialise, bool bForceRecovery, + Checks const checks) : m_aMutexHolder(std::move( aMutexHolder )) +, m_Checks(checks) , aGrabber( xInput ) , aInflater( true ) , xStream(xInput) @@ -1165,7 +1148,7 @@ sal_Int32 ZipFile::readCEN() } // this is required for OOXML, but not for ODF auto const lowerPath(aEntry.sPath.toAsciiLowerCase()); - if (!m_EntriesInsensitive.insert(lowerPath).second) + if (!m_EntriesInsensitive.insert(lowerPath).second && m_Checks == Checks::CheckInsensitive) { SAL_INFO("package", "Duplicate CEN entry (case insensitive): \"" << aEntry.sPath << "\""); throw ZipException(u"Duplicate CEN entry (case insensitive)"_ustr); diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index a1aff4c54042..ccd68b9e86d0 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -844,7 +844,9 @@ void SAL_CALL ZipPackage::initialize( const uno::Sequence< Any >& aArguments ) OUString message; try { - m_pZipFile.emplace(m_aMutexHolder, m_xContentStream, m_xContext, true, m_bForceRecovery); + m_pZipFile.emplace(m_aMutexHolder, m_xContentStream, m_xContext, true, + m_bForceRecovery, + m_nFormat == embed::StorageFormats::ZIP ? ZipFile::Checks::Default : ZipFile::Checks::CheckInsensitive); getZipFileContents(); } catch ( IOException & e ) @@ -1217,7 +1219,9 @@ void ZipPackage::ConnectTo( const uno::Reference< io::XInputStream >& xInStream if ( m_pZipFile ) m_pZipFile->setInputStream( m_xContentStream ); else - m_pZipFile.emplace(m_aMutexHolder, m_xContentStream, m_xContext, false); + m_pZipFile.emplace(m_aMutexHolder, m_xContentStream, m_xContext, false, + false, + m_nFormat == embed::StorageFormats::ZIP ? ZipFile::Checks::Default : ZipFile::Checks::CheckInsensitive); } namespace diff --git a/package/source/zippackage/zipfileaccess.cxx b/package/source/zippackage/zipfileaccess.cxx index d693a51ceceb..bd7caaf279e6 100644 --- a/package/source/zippackage/zipfileaccess.cxx +++ b/package/source/zippackage/zipfileaccess.cxx @@ -244,7 +244,7 @@ void SAL_CALL OZipFileAccess::initialize( const uno::Sequence< uno::Any >& aArgu m_aMutexHolder, m_xContentStream, m_xContext, - true ); + true, false, ZipFile::Checks::Default); } // XNameAccess