package/inc/ZipFile.hxx | 2 +- package/source/zipapi/ZipFile.cxx | 11 +++++++++++ package/source/zippackage/ZipPackage.cxx | 12 ++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-)
New commits: commit 09c16904bbac8079428041e7802334c43395c8a6 Author: Michael Stahl <[email protected]> AuthorDate: Mon Sep 16 20:31:06 2024 +0200 Commit: Caolán McNamara <[email protected]> CommitDate: Thu Sep 19 09:21:44 2024 +0200 tdf#162866 package: fix loading AutoCorrect file with case-insensitive ... duplicates; the directory names of AutoCorrect entries are user-editable, so this needs to be supported. AutoCorrect uses an ODF package because the ODF document loading code requires the ODF document to be in an ODF storage with a MediaType property. AutoCorrect writes an empty mimetype file, and if such is present in an .odt file that is being loaded, existing checks will detect it as corrupted, so we can use this to check that the file is an AutoCorrect file and turn off the case-insensitive check. (regression from commit 4833f131243bdb409ddfaff8b4db87d4ed2af98f) Change-Id: I43887f7dad0c8cbb465b4c0f1c38bcc3244a7675 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173477 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins (cherry picked from commit 9012355a60bd88db582078e38123863a4959b72f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173493 Reviewed-by: Caolán McNamara <[email protected]> diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx index 906f1fc5bd82..71f38cc3ebb4 100644 --- a/package/inc/ZipFile.hxx +++ b/package/inc/ZipFile.hxx @@ -54,7 +54,7 @@ class ZipEnumeration; class ZipFile { public: - enum class Checks { Default, CheckInsensitive }; + enum class Checks { Default, CheckInsensitive, TryCheckInsensitive }; private: rtl::Reference<comphelper::RefCountedMutex> m_aMutexHolder; diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index 01a8c16e2842..2e82433fb0da 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -1470,6 +1470,17 @@ sal_Int32 ZipFile::readCEN() SAL_INFO("package", "Duplicate CEN entry: \"" << aEntry.sPath << "\""); throw ZipException(u"Duplicate CEN entry"_ustr); } + if (aEntries.empty() && m_Checks == Checks::TryCheckInsensitive) + { + if (aEntry.sPath == "mimetype" && aEntry.nSize == 0) + { // tdf#162866 AutoCorrect uses ODF package, directories are + m_Checks = Checks::Default; // user-defined => ignore! + } + else + { + m_Checks = Checks::CheckInsensitive; + } + } // this is required for OOXML, but not for ODF auto const lowerPath(aEntry.sPath.toAsciiLowerCase()); if (!m_EntriesInsensitive.insert(lowerPath).second && m_Checks == Checks::CheckInsensitive) diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 89891784ff8e..116cf8dcb1a7 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -898,7 +898,11 @@ void SAL_CALL ZipPackage::initialize( const uno::Sequence< Any >& aArguments ) { m_pZipFile.emplace(m_aMutexHolder, m_xContentStream, m_xContext, true, m_bForceRecovery, - m_nFormat == embed::StorageFormats::ZIP ? ZipFile::Checks::Default : ZipFile::Checks::CheckInsensitive); + m_nFormat == embed::StorageFormats::ZIP + ? ZipFile::Checks::Default + : m_nFormat == embed::StorageFormats::OFOPXML + ? ZipFile::Checks::CheckInsensitive + : ZipFile::Checks::TryCheckInsensitive); getZipFileContents(); } catch ( IOException & e ) @@ -1273,7 +1277,11 @@ void ZipPackage::ConnectTo( const uno::Reference< io::XInputStream >& xInStream else m_pZipFile.emplace(m_aMutexHolder, m_xContentStream, m_xContext, false, false, - m_nFormat == embed::StorageFormats::ZIP ? ZipFile::Checks::Default : ZipFile::Checks::CheckInsensitive); + m_nFormat == embed::StorageFormats::ZIP + ? ZipFile::Checks::Default + : m_nFormat == embed::StorageFormats::OFOPXML + ? ZipFile::Checks::CheckInsensitive + : ZipFile::Checks::TryCheckInsensitive); } namespace
