From e8462821280627d826dfed17294ef30edd81e920 Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Fri, 2 Oct 2020 16:43:43 +0300 Subject: [PATCH] fix bug wells-wheels-of-chance --- EpubFile/src/CEpubFile.cpp | 19 +++++++++++++++++-- HtmlFile2/htmlfile2.cpp | 3 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/EpubFile/src/CEpubFile.cpp b/EpubFile/src/CEpubFile.cpp index 9f0790abd1..c27f0d8926 100644 --- a/EpubFile/src/CEpubFile.cpp +++ b/EpubFile/src/CEpubFile.cpp @@ -52,9 +52,24 @@ HRESULT CEpubFile::Convert(const std::wstring& sInputFile, const std::wstring& s if (oOfficeUtils.ExtractToDirectory(sInputFile, m_sTempDir.c_str(), password, 1) != S_OK) return S_FALSE; - XmlUtils::CXmlLiteReader oXmlLiteReader; + std::wstring sFileContent; + std::wstring sContent; + if(!NSFile::CFileBinary::ReadAllTextUtf8(m_sTempDir + L"/container.xml", sFileContent)) + return S_FALSE; + size_t nContent = sFileContent.find(L"full-path"); + if(nContent != std::wstring::npos) + { + nContent += 11; + sContent = sFileContent.substr(nContent, sFileContent.find(L'\"', nContent) - nContent); + size_t posLastSlash = sContent.rfind(L'/'); + if (posLastSlash != std::wstring::npos) + sContent = sContent.substr(posLastSlash + 1); + } + sContent = m_sTempDir + (sContent.empty() ? L"/content.opf" : L'/' + sContent); - if (oXmlLiteReader.FromFile(m_sTempDir + L"/content.opf")) + + XmlUtils::CXmlLiteReader oXmlLiteReader; + if (oXmlLiteReader.FromFile(sContent)) { oXmlLiteReader.ReadNextNode(); int nParentDepth = oXmlLiteReader.GetDepth(); diff --git a/HtmlFile2/htmlfile2.cpp b/HtmlFile2/htmlfile2.cpp index 303efcbaf3..c2a138bae9 100644 --- a/HtmlFile2/htmlfile2.cpp +++ b/HtmlFile2/htmlfile2.cpp @@ -362,7 +362,8 @@ public: // Конвертирует html в xhtml bool htmlXhtml(const std::wstring& sSrc) { - if(NSFile::GetFileExtention(sSrc) != L"xhtml") + std::wstring sExtention = NSFile::GetFileExtention(sSrc); + if(sExtention != L"xhtml") { std::wstring sRes = htmlToXhtml(sSrc); /*