diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2024-09-16 20:31:06 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2024-09-17 10:40:29 +0200 |
commit | 9012355a60bd88db582078e38123863a4959b72f (patch) | |
tree | f513b799c90495abf05d5d97295a97b62c042d5e /package | |
parent | eae540e38b3841d88e9102f9977a3ced953d7864 (diff) |
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 <michael.stahl@allotropia.de>
Tested-by: Jenkins
Diffstat (limited to 'package')
-rw-r--r-- | package/inc/ZipFile.hxx | 2 | ||||
-rw-r--r-- | package/source/zipapi/ZipFile.cxx | 11 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackage.cxx | 12 |
3 files changed, 22 insertions, 3 deletions
diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx index 72b053363f61..b7612061b11c 100644 --- a/package/inc/ZipFile.hxx +++ b/package/inc/ZipFile.hxx @@ -56,7 +56,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 7b55d2bea684..a16552d43ece 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -1500,6 +1500,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 a5dcc5b76e6b..85efe2003149 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -896,7 +896,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 ) @@ -1270,7 +1274,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); } uno::Reference< io::XInputStream > ZipPackage::writeTempFile() |