summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2024-07-17 12:04:13 +0200
committerAndras Timar <andras.timar@collabora.com>2024-08-23 11:17:11 +0200
commit84276bb49252017719a8c23c06dc6459d8582ffe (patch)
treeba400a56cdfef6be58884b3572ba544bee1ded43 /package
parent9bdde672e56c533b56fdd316d1f6cd5cbacfea63 (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/+/170623 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'package')
-rw-r--r--package/inc/ZipFile.hxx13
-rw-r--r--package/source/zipapi/ZipFile.cxx25
-rw-r--r--package/source/zippackage/ZipPackage.cxx8
-rw-r--r--package/source/zippackage/zipfileaccess.cxx2
4 files changed, 18 insertions, 30 deletions
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;
@@ -98,13 +103,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 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 9de596fe5310..8b24e7989480 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 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