Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Reader/EpubBook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,10 @@ BOOL EpubBook::ParserOps(file_data_t *fdata, wchar_t **text, int *len, wchar_t *
}

xmlKeepBlanksDefault(1);
doc = xmlReadMemory((const char *)format_str, size, NULL, NULL, XML_PARSE_RECOVER/* | XML_PARSE_NOBLANKS*/);
// htmlDocDumpMemoryFormat may serialize characters such as curly quotes as
// HTML named entities. Reparse the formatted document as HTML so those
// entities survive instead of being discarded by the XML parser.
doc = htmlReadMemory((const char *)format_str, size, NULL, NULL, HTML_PARSE_RECOVER);
xmlFree(format_str);
if (!doc)
goto end;
Expand Down Expand Up @@ -1048,4 +1051,4 @@ BOOL EpubBook::ParserCover(epub_t &epub)
}

return m_Cover != NULL;
}
}
5 changes: 3 additions & 2 deletions Reader/MobiBook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,12 @@ BOOL MobiBook::ParserOps(file_data_t *fdata, wchar_t **text, int *len, wchar_t *
}

xmlKeepBlanksDefault(1);
doc = xmlReadMemory((const char *)format_str, size, NULL, NULL, XML_PARSE_RECOVER | XML_PARSE_HUGE /*| XML_PARSE_NOBLANKS */ ); //XML_PARSE_HUGE 大文件支持
// htmlDocDumpMemoryFormat can emit HTML named entities. The XML parser only
// understands XML's predefined entities and would silently lose others.
doc = htmlReadMemory((const char *)format_str, size, NULL, NULL, HTML_PARSE_RECOVER);
xmlFree(format_str);
if (!doc)
goto end;
xmlDocDumpFormatMemory(doc, &format_str, &size, 1);
#endif

xpathctx = xmlXPathNewContext(doc);
Expand Down