Skip to content

Commit

Permalink
Check early that provided bookIds are valid
Browse files Browse the repository at this point in the history
  • Loading branch information
mgautierfr committed May 31, 2022
1 parent 3ffe4b3 commit 995d15f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/server/internalServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ std::pair<std::string, Library::BookIdSet> InternalServer::selectBooks(const Req
if (id_vec.empty()) {
throw Error(noValueForArgMsg(prefix+"id"));
}
for(const auto& bookId: id_vec) {
try {
// This is a silly way to check that bookId exists
mp_nameMapper->getNameForId(bookId);
} catch (const std::out_of_range&) {
throw Error(noSuchBookErrorMsg(bookId));
}
}
const auto bookIds = Library::BookIdSet(id_vec.begin(), id_vec.end());
checkBookNumber(bookIds, m_multizimSearchLimit);
const auto queryString = request.get_query([&](const std::string& key){return key == prefix+"id";}, true);
Expand Down

0 comments on commit 995d15f

Please sign in to comment.