diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2024-07-17 12:04:13 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2024-07-18 21:59:51 +0200 |
commit | 9bba9dede3def626e3adab6696a911762e25b7ff (patch) | |
tree | 625dda3ca8f6580d8dba5dcf4d532534b4171248 /package | |
parent | 1636bce46df5f762eca594f5ebb05db7187287a0 (diff) |
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.stahl@allotropia.de>
(cherry picked from commit 0fb25ce9ff9a3ede8d43ee1502c44b4c02135b3f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170564
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'package')
-rw-r--r-- | package/inc/ZipFile.hxx | 13 | ||||
-rw-r--r-- | package/source/zipapi/ZipFile.cxx | 25 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackage.cxx | 8 | ||||
-rw-r--r-- | package/source/zippackage/zipfileaccess.cxx | 2 |
4 files changed, 18 insertions, 30 deletions
diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx index ed9847a30013..491309d9bd68 100644 --- a/package/inc/ZipFile.hxx +++ b/package/inc/ZipFile.hxx @@ -55,9 +55,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; @@ -103,13 +108,9 @@ 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 5fa21941b8b6..e46d7c561e34 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( u"stream data looks to be broken"_ustr ); - } -} - 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) @@ -1353,7 +1336,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 2cb267734b9f..db4a61d8ddb4 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); } uno::Reference< io::XInputStream > ZipPackage::writeTempFile() diff --git a/package/source/zippackage/zipfileaccess.cxx b/package/source/zippackage/zipfileaccess.cxx index 0b659a420e73..25944a23e3de 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 |