diff options
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 |