More review changes
This commit is contained in:
@@ -267,18 +267,25 @@ void XMLCALL ContentOpfParser::startElement(void* userData, const XML_Char* name
|
||||
}
|
||||
|
||||
// EPUB 3 collection metadata:
|
||||
// <meta property="belongs-to-collection">Series Name</meta>
|
||||
// <meta property="belongs-to-collection">Series Name</meta> (character data)
|
||||
// <meta property="belongs-to-collection" content="Series Name"/> (attribute, some generators)
|
||||
// <meta property="group-position">1</meta>
|
||||
if (metaProperty) {
|
||||
if (strcmp(metaProperty, "belongs-to-collection") == 0 && self->series.empty()) {
|
||||
self->series.clear();
|
||||
self->state = IN_BOOK_SERIES;
|
||||
return;
|
||||
if (metaContent) {
|
||||
self->series = std::string(metaContent).substr(0, MAX_DESCRIPTION_LENGTH);
|
||||
} else {
|
||||
self->state = IN_BOOK_SERIES;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (strcmp(metaProperty, "group-position") == 0 && self->seriesIndex.empty()) {
|
||||
self->seriesIndex.clear();
|
||||
self->state = IN_BOOK_SERIES_INDEX;
|
||||
return;
|
||||
if (metaContent) {
|
||||
self->seriesIndex = std::string(metaContent).substr(0, MAX_DESCRIPTION_LENGTH);
|
||||
} else {
|
||||
self->state = IN_BOOK_SERIES_INDEX;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,10 @@ constexpr uint32_t MAX_STRING_LENGTH = 4096;
|
||||
static bool readString(std::istream& is, std::string& s) {
|
||||
uint32_t len;
|
||||
readPod(is, len);
|
||||
if (len > MAX_STRING_LENGTH) return false;
|
||||
if (len > MAX_STRING_LENGTH) {
|
||||
is.seekg(len, std::ios::cur); // skip payload to keep stream aligned
|
||||
return false;
|
||||
}
|
||||
s.resize(len);
|
||||
is.read(&s[0], len);
|
||||
return true;
|
||||
@@ -50,7 +53,10 @@ static bool readString(std::istream& is, std::string& s) {
|
||||
static bool readString(FsFile& file, std::string& s) {
|
||||
uint32_t len;
|
||||
readPod(file, len);
|
||||
if (len > MAX_STRING_LENGTH) return false;
|
||||
if (len > MAX_STRING_LENGTH) {
|
||||
file.seekCur(len); // skip payload to keep file position aligned
|
||||
return false;
|
||||
}
|
||||
s.resize(len);
|
||||
file.read(reinterpret_cast<uint8_t*>(&s[0]), len);
|
||||
return true;
|
||||
|
||||
@@ -122,8 +122,8 @@ bool RecentBooksStore::loadFromBinaryFile() {
|
||||
// Old version, just read paths
|
||||
uint8_t count;
|
||||
serialization::readPod(inputFile, count);
|
||||
recentBooks.clear();
|
||||
recentBooks.reserve(count);
|
||||
std::vector<RecentBook> tmpRecentBooks;
|
||||
tmpRecentBooks.reserve(count);
|
||||
for (uint8_t i = 0; i < count; i++) {
|
||||
std::string path;
|
||||
if (!serialization::readString(inputFile, path)) {
|
||||
@@ -142,17 +142,18 @@ bool RecentBooksStore::loadFromBinaryFile() {
|
||||
inputFile.close();
|
||||
return false;
|
||||
}
|
||||
recentBooks.push_back({path, title, author, "", ""});
|
||||
tmpRecentBooks.push_back({path, title, author, "", ""});
|
||||
} else {
|
||||
recentBooks.push_back(book);
|
||||
tmpRecentBooks.push_back(book);
|
||||
}
|
||||
}
|
||||
recentBooks = std::move(tmpRecentBooks);
|
||||
} else if (version == 3) {
|
||||
uint8_t count;
|
||||
serialization::readPod(inputFile, count);
|
||||
|
||||
recentBooks.clear();
|
||||
recentBooks.reserve(count);
|
||||
std::vector<RecentBook> tmpRecentBooks;
|
||||
tmpRecentBooks.reserve(count);
|
||||
uint8_t omitted = 0;
|
||||
|
||||
for (uint8_t i = 0; i < count; i++) {
|
||||
@@ -170,8 +171,9 @@ bool RecentBooksStore::loadFromBinaryFile() {
|
||||
continue;
|
||||
}
|
||||
|
||||
recentBooks.push_back({path, title, author, "", coverBmpPath});
|
||||
tmpRecentBooks.push_back({path, title, author, "", coverBmpPath});
|
||||
}
|
||||
recentBooks = std::move(tmpRecentBooks);
|
||||
|
||||
if (omitted > 0) {
|
||||
inputFile.close();
|
||||
|
||||
Reference in New Issue
Block a user