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>
This commit is contained in:
@@ -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;
|
||||
@@ -100,16 +105,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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user