From 382655d83c5532f3e8eeab6abe32a5b042892cb6 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Mon, 6 Nov 2017 12:10:48 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Explicitly=20set=20ctpp2=20iIMaxSteps=20to?= =?UTF-8?q?=20extends=20search=20beyond=2068=C2=A0results.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ctpp2 templates have a limit step number. If the template to render is too big, the rendering fails, throwing an exception. From our tests, it seems that, with the template we have, the default step limit allow us to render 68 results only. By doubling the limit, we can render up to 144 results. --- src/searcher.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/searcher.cpp b/src/searcher.cpp index 4d7038a16..1b1b0f004 100644 --- a/src/searcher.cpp +++ b/src/searcher.cpp @@ -298,7 +298,12 @@ int _Result::get_readerIndex() string Searcher::getHtml() { - SimpleVM oSimpleVM; + SimpleVM oSimpleVM( + 1024, //iIMaxFunctions (default value) + 4096, //iIMaxArgStackSize (default value) + 4096, //iIMaxCodeStackSize (default value) + 10240 * 2 //iIMaxSteps (default*2) + ); // Fill data CDT oData; From 0e8c8f68c54f4fbaee9fc2002e969ae29bfc18ab Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Mon, 6 Nov 2017 12:13:54 +0100 Subject: [PATCH 2/2] Extend search limits to 140. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 70 is a too small limit for the number of results. Users need at least 100. As the html rendering will fails with more than 144 results, explicitly limits the number of search to 140. Fixes kiwix/kiwix-tools#92 --- src/searcher.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/searcher.cpp b/src/searcher.cpp index 1b1b0f004..8c5a27ad8 100644 --- a/src/searcher.cpp +++ b/src/searcher.cpp @@ -33,6 +33,8 @@ using namespace CTPP; #endif +#define MAX_SEARCH_LEN 140 + namespace kiwix { class _Result : public Result @@ -141,9 +143,9 @@ void Searcher::search(std::string& search, if (resultStart != resultEnd) { /* Avoid big researches */ this->resultCountPerPage = resultEnd - resultStart; - if (this->resultCountPerPage > 70) { - resultEnd = resultStart + 70; - this->resultCountPerPage = 70; + if (this->resultCountPerPage > MAX_SEARCH_LEN) { + resultEnd = resultStart + MAX_SEARCH_LEN; + this->resultCountPerPage = MAX_SEARCH_LEN; } /* Perform the search */