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 4833f13124)
Change-Id: I43887f7dad0c8cbb465b4c0f1c38bcc3244a7675
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173477
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Tested-by: Jenkins
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user