mirror of https://github.com/kiwix/libkiwix.git
FIXED: kiwix-serve crash if unattended search "start" & "end" values
This commit is contained in:
parent
518ce6635d
commit
f585bed1cb
|
@ -39,21 +39,39 @@ namespace kiwix {
|
|||
}
|
||||
|
||||
/* Search strings in the database */
|
||||
void Searcher::search(std::string &search, const unsigned int resultStart,
|
||||
const unsigned int resultEnd, const bool verbose) {
|
||||
void Searcher::search(std::string &search, unsigned int resultStart,
|
||||
unsigned int resultEnd, const bool verbose) {
|
||||
this->reset();
|
||||
|
||||
if (verbose == true) {
|
||||
cout << "Performing query `" << search << "'" << endl;
|
||||
}
|
||||
|
||||
this->searchPattern = search;
|
||||
/* If resultEnd & resultStart inverted */
|
||||
if (resultStart > resultEnd) {
|
||||
resultEnd += resultStart;
|
||||
resultStart = resultEnd - resultStart;
|
||||
resultEnd -= resultStart;
|
||||
}
|
||||
|
||||
/* Try to find results */
|
||||
if (resultStart != resultEnd) {
|
||||
|
||||
/* Avoid big researches */
|
||||
this->resultCountPerPage = resultEnd - resultStart;
|
||||
if (this->resultCountPerPage > 70) {
|
||||
resultEnd = resultStart + 70;
|
||||
this->resultCountPerPage = 70;
|
||||
}
|
||||
|
||||
/* Perform the search */
|
||||
this->searchPattern = search;
|
||||
this->resultStart = resultStart;
|
||||
this->resultEnd = resultEnd;
|
||||
string unaccentedSearch = removeAccents(search);
|
||||
searchInIndex(unaccentedSearch, resultStart, resultEnd, verbose);
|
||||
this->resultOffset = this->results.begin();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -59,8 +59,8 @@ namespace kiwix {
|
|||
public:
|
||||
Searcher();
|
||||
|
||||
void search(std::string &search, const unsigned int resultStart,
|
||||
const unsigned int resultEnd, const bool verbose=false);
|
||||
void search(std::string &search, unsigned int resultStart,
|
||||
unsigned int resultEnd, const bool verbose=false);
|
||||
bool getNextResult(string &url, string &title, unsigned int &score);
|
||||
unsigned int getEstimatedResultCount();
|
||||
bool setProtocolPrefix(const std::string prefix);
|
||||
|
|
|
@ -38703,20 +38703,21 @@ const unsigned char server_taskbar_css[]={
|
|||
0x69,0x78,0x73,0x65,0x61,0x72,0x63,0x68,0x62,0x6f,0x78,0x20,0x7b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x6d,0x61,0x72,0x67,0x69,0x6e,0x3a,0x20,0x30,0x70,0x78,0x3b,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3a,0x20,0x72,0x69,0x67,0x68,0x74,0x3b,
|
||||
0x0a,0x7d,0x0a,0x0a,0x23,0x6b,0x69,0x77,0x69,0x78,0x73,0x65,0x61,0x72,0x63,0x68,
|
||||
0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x72,0x67,0x69,0x6e,0x3a,0x20,0x30,
|
||||
0x70,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3a,0x20,0x72,
|
||||
0x69,0x67,0x68,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x2f,0x2a,0x20,0x54,0x72,0x79,0x20,
|
||||
0x74,0x6f,0x20,0x66,0x69,0x78,0x20,0x62,0x75,0x67,0x67,0x79,0x20,0x73,0x74,0x75,
|
||||
0x66,0x66,0x20,0x69,0x6e,0x20,0x6a,0x71,0x75,0x65,0x72,0x79,0x2d,0x75,0x69,0x20,
|
||||
0x61,0x75,0x74,0x6f,0x63,0x6f,0x6d,0x70,0x6c,0x65,0x74,0x65,0x20,0x2a,0x2f,0x0a,
|
||||
0x23,0x75,0x69,0x2d,0x69,0x64,0x2d,0x31,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x62,
|
||||
0x61,0x63,0x6b,0x67,0x72,0x6f,0x75,0x6e,0x64,0x3a,0x20,0x77,0x68,0x69,0x74,0x65,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x62,0x6f,0x72,0x64,0x65,0x72,0x3a,0x20,0x73,0x6f,
|
||||
0x6c,0x69,0x64,0x20,0x31,0x70,0x78,0x20,0x67,0x72,0x65,0x79,0x3b,0x0a,0x7d,0x0a,
|
||||
0x0a,0x6c,0x69,0x2e,0x75,0x69,0x2d,0x73,0x74,0x61,0x74,0x65,0x2d,0x66,0x6f,0x63,
|
||||
0x75,0x73,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x6e,0x74,0x2d,0x77,0x65,
|
||||
0x69,0x67,0x68,0x74,0x3a,0x20,0x62,0x6f,0x6c,0x64,0x3b,0x0a,0x7d
|
||||
0x0a,0x20,0x20,0x20,0x20,0x77,0x69,0x64,0x74,0x68,0x3a,0x20,0x33,0x30,0x30,0x70,
|
||||
0x78,0x3b,0x0a,0x7d,0x0a,0x0a,0x23,0x6b,0x69,0x77,0x69,0x78,0x73,0x65,0x61,0x72,
|
||||
0x63,0x68,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x72,0x67,0x69,0x6e,0x3a,
|
||||
0x20,0x30,0x70,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3a,
|
||||
0x20,0x72,0x69,0x67,0x68,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x2f,0x2a,0x20,0x54,0x72,
|
||||
0x79,0x20,0x74,0x6f,0x20,0x66,0x69,0x78,0x20,0x62,0x75,0x67,0x67,0x79,0x20,0x73,
|
||||
0x74,0x75,0x66,0x66,0x20,0x69,0x6e,0x20,0x6a,0x71,0x75,0x65,0x72,0x79,0x2d,0x75,
|
||||
0x69,0x20,0x61,0x75,0x74,0x6f,0x63,0x6f,0x6d,0x70,0x6c,0x65,0x74,0x65,0x20,0x2a,
|
||||
0x2f,0x0a,0x23,0x75,0x69,0x2d,0x69,0x64,0x2d,0x31,0x20,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x62,0x61,0x63,0x6b,0x67,0x72,0x6f,0x75,0x6e,0x64,0x3a,0x20,0x77,0x68,0x69,
|
||||
0x74,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x62,0x6f,0x72,0x64,0x65,0x72,0x3a,0x20,
|
||||
0x73,0x6f,0x6c,0x69,0x64,0x20,0x31,0x70,0x78,0x20,0x67,0x72,0x65,0x79,0x3b,0x0a,
|
||||
0x7d,0x0a,0x0a,0x6c,0x69,0x2e,0x75,0x69,0x2d,0x73,0x74,0x61,0x74,0x65,0x2d,0x66,
|
||||
0x6f,0x63,0x75,0x73,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6f,0x6e,0x74,0x2d,
|
||||
0x77,0x65,0x69,0x67,0x68,0x74,0x3a,0x20,0x62,0x6f,0x6c,0x64,0x3b,0x0a,0x7d
|
||||
};
|
||||
|
||||
const unsigned char server_include_html_part[]={
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#kiwixsearchbox {
|
||||
margin: 0px;
|
||||
float: right;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
#kiwixsearch {
|
||||
|
|
Loading…
Reference in New Issue