From 9182a0567057eebf551b4f286da5af6c492a4ea7 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Sun, 8 Mar 2026 12:14:18 +0100 Subject: [PATCH] And more... --- lib/Epub/Epub/parsers/ContentOpfParser.cpp | 8 ++++---- lib/Serialization/Serialization.h | 4 +++- src/RecentBooksStore.cpp | 6 ++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/Epub/Epub/parsers/ContentOpfParser.cpp b/lib/Epub/Epub/parsers/ContentOpfParser.cpp index 4818558e..8ff97d80 100644 --- a/lib/Epub/Epub/parsers/ContentOpfParser.cpp +++ b/lib/Epub/Epub/parsers/ContentOpfParser.cpp @@ -260,9 +260,9 @@ void XMLCALL ContentOpfParser::startElement(void* userData, const XML_Char* name if (strcmp(metaName, "cover") == 0) { self->coverItemId = metaContent; } else if (strcmp(metaName, "calibre:series") == 0 && self->series.empty()) { - self->series = std::string(metaContent).substr(0, MAX_DESCRIPTION_LENGTH); + self->series = trim(std::string(metaContent)).substr(0, MAX_DESCRIPTION_LENGTH); } else if (strcmp(metaName, "calibre:series_index") == 0 && self->seriesIndex.empty()) { - self->seriesIndex = std::string(metaContent).substr(0, MAX_DESCRIPTION_LENGTH); + self->seriesIndex = trim(std::string(metaContent)).substr(0, MAX_DESCRIPTION_LENGTH); } } @@ -273,7 +273,7 @@ void XMLCALL ContentOpfParser::startElement(void* userData, const XML_Char* name if (metaProperty) { if (strcmp(metaProperty, "belongs-to-collection") == 0 && self->series.empty()) { if (metaContent) { - self->series = std::string(metaContent).substr(0, MAX_DESCRIPTION_LENGTH); + self->series = trim(std::string(metaContent)).substr(0, MAX_DESCRIPTION_LENGTH); } else { self->state = IN_BOOK_SERIES; return; @@ -281,7 +281,7 @@ void XMLCALL ContentOpfParser::startElement(void* userData, const XML_Char* name } if (strcmp(metaProperty, "group-position") == 0 && self->seriesIndex.empty()) { if (metaContent) { - self->seriesIndex = std::string(metaContent).substr(0, MAX_DESCRIPTION_LENGTH); + self->seriesIndex = trim(std::string(metaContent)).substr(0, MAX_DESCRIPTION_LENGTH); } else { self->state = IN_BOOK_SERIES_INDEX; return; diff --git a/lib/Serialization/Serialization.h b/lib/Serialization/Serialization.h index c1be4982..e5a885cc 100644 --- a/lib/Serialization/Serialization.h +++ b/lib/Serialization/Serialization.h @@ -54,7 +54,9 @@ static bool readString(FsFile& file, std::string& s) { uint32_t len; readPod(file, len); if (len > MAX_STRING_LENGTH) { - file.seekCur(len); // skip payload to keep file position aligned + if (!file.seekCur(static_cast(len))) { // skip payload to keep file position aligned + return false; + } return false; } s.resize(len); diff --git a/src/RecentBooksStore.cpp b/src/RecentBooksStore.cpp index 53a0f333..ff811cd8 100644 --- a/src/RecentBooksStore.cpp +++ b/src/RecentBooksStore.cpp @@ -142,8 +142,10 @@ bool RecentBooksStore::loadFromBinaryFile() { inputFile.close(); return false; } - tmpRecentBooks.push_back({path, title, author, "", ""}); - } else { + if (!title.empty()) { + tmpRecentBooks.push_back({path, title, author, "", ""}); + } + } else if (!book.title.empty()) { tmpRecentBooks.push_back(book); } }