mirror of https://github.com/kiwix/libkiwix.git
+ fix fulltext result page for pattern including mustbeurlencoded characters
This commit is contained in:
parent
bb62f3aa94
commit
306b7ebbb0
|
@ -197,6 +197,8 @@ namespace kiwix {
|
||||||
|
|
||||||
oData["count"] = kiwix::beautifyInteger(this->estimatedResultCount);
|
oData["count"] = kiwix::beautifyInteger(this->estimatedResultCount);
|
||||||
oData["searchPattern"] = this->searchPattern;
|
oData["searchPattern"] = this->searchPattern;
|
||||||
|
std::cout << urlEncode(this->searchPattern) << std::endl;
|
||||||
|
oData["searchPatternEncoded"] = urlEncode(this->searchPattern);
|
||||||
oData["resultStart"] = this->resultStart + 1;
|
oData["resultStart"] = this->resultStart + 1;
|
||||||
oData["resultEnd"] = (this->resultEnd > this->estimatedResultCount ? this->estimatedResultCount : this->resultEnd);
|
oData["resultEnd"] = (this->resultEnd > this->estimatedResultCount ? this->estimatedResultCount : this->resultEnd);
|
||||||
oData["resultRange"] = this->resultRange;
|
oData["resultRange"] = this->resultRange;
|
||||||
|
|
|
@ -160,47 +160,48 @@ const unsigned char results_tmpl[]={
|
||||||
0x78,0x3e,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x3d,0x3c,0x54,0x4d,0x50,0x4c,0x5f,
|
0x78,0x3e,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x3d,0x3c,0x54,0x4d,0x50,0x4c,0x5f,
|
||||||
0x76,0x61,0x72,0x20,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x49,0x64,0x3e,0x26,0x70,
|
0x76,0x61,0x72,0x20,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x49,0x64,0x3e,0x26,0x70,
|
||||||
0x61,0x74,0x74,0x65,0x72,0x6e,0x3d,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,
|
0x61,0x74,0x74,0x65,0x72,0x6e,0x3d,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,
|
||||||
0x20,0x73,0x65,0x61,0x72,0x63,0x68,0x50,0x61,0x74,0x74,0x65,0x72,0x6e,0x3e,0x26,
|
0x20,0x73,0x65,0x61,0x72,0x63,0x68,0x50,0x61,0x74,0x74,0x65,0x72,0x6e,0x45,0x6e,
|
||||||
0x73,0x74,0x61,0x72,0x74,0x3d,0x30,0x26,0x65,0x6e,0x64,0x3d,0x3c,0x54,0x4d,0x50,
|
0x63,0x6f,0x64,0x65,0x64,0x3e,0x26,0x73,0x74,0x61,0x72,0x74,0x3d,0x30,0x26,0x65,
|
||||||
0x4c,0x5f,0x76,0x61,0x72,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x52,0x61,0x6e,0x67,
|
0x6e,0x64,0x3d,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,0x20,0x72,0x65,0x73,
|
||||||
0x65,0x3e,0x22,0x3e,0xe2,0x97,0x80,0x3c,0x2f,0x61,0x3e,0x3c,0x2f,0x6c,0x69,0x3e,
|
0x75,0x6c,0x74,0x52,0x61,0x6e,0x67,0x65,0x3e,0x22,0x3e,0xe2,0x97,0x80,0x3c,0x2f,
|
||||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x3c,0x2f,0x54,0x4d,0x50,0x4c,0x5f,0x69,0x66,
|
0x61,0x3e,0x3c,0x2f,0x6c,0x69,0x3e,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x3c,0x2f,
|
||||||
0x3e,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x6c,0x6f,
|
0x54,0x4d,0x50,0x4c,0x5f,0x69,0x66,0x3e,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x3c,
|
||||||
0x6f,0x70,0x20,0x70,0x61,0x67,0x65,0x73,0x3e,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
0x54,0x4d,0x50,0x4c,0x5f,0x6c,0x6f,0x6f,0x70,0x20,0x70,0x61,0x67,0x65,0x73,0x3e,
|
||||||
0x3c,0x6c,0x69,0x3e,0x3c,0x61,0x20,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x69,0x66,0x20,
|
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x3c,0x6c,0x69,0x3e,0x3c,0x61,0x20,0x3c,0x54,
|
||||||
0x73,0x65,0x6c,0x65,0x63,0x74,0x65,0x64,0x3e,0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,
|
0x4d,0x50,0x4c,0x5f,0x69,0x66,0x20,0x73,0x65,0x6c,0x65,0x63,0x74,0x65,0x64,0x3e,
|
||||||
0x73,0x65,0x6c,0x65,0x63,0x74,0x65,0x64,0x22,0x3c,0x2f,0x54,0x4d,0x50,0x4c,0x5f,
|
0x63,0x6c,0x61,0x73,0x73,0x3d,0x22,0x73,0x65,0x6c,0x65,0x63,0x74,0x65,0x64,0x22,
|
||||||
0x69,0x66,0x3e,0x20,0x68,0x72,0x65,0x66,0x3d,0x22,0x3c,0x54,0x4d,0x50,0x4c,0x5f,
|
0x3c,0x2f,0x54,0x4d,0x50,0x4c,0x5f,0x69,0x66,0x3e,0x20,0x68,0x72,0x65,0x66,0x3d,
|
||||||
0x76,0x61,0x72,0x20,0x73,0x65,0x61,0x72,0x63,0x68,0x50,0x72,0x6f,0x74,0x6f,0x63,
|
0x22,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,0x20,0x73,0x65,0x61,0x72,0x63,
|
||||||
0x6f,0x6c,0x50,0x72,0x65,0x66,0x69,0x78,0x3e,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,
|
0x68,0x50,0x72,0x6f,0x74,0x6f,0x63,0x6f,0x6c,0x50,0x72,0x65,0x66,0x69,0x78,0x3e,
|
||||||
0x3d,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,0x20,0x63,0x6f,0x6e,0x74,0x65,
|
0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x3d,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,
|
||||||
0x6e,0x74,0x49,0x64,0x3e,0x26,0x70,0x61,0x74,0x74,0x65,0x72,0x6e,0x3d,0x3c,0x54,
|
0x72,0x20,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x49,0x64,0x3e,0x26,0x70,0x61,0x74,
|
||||||
0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,0x20,0x73,0x65,0x61,0x72,0x63,0x68,0x50,0x61,
|
0x74,0x65,0x72,0x6e,0x3d,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,0x20,0x73,
|
||||||
0x74,0x74,0x65,0x72,0x6e,0x3e,0x26,0x73,0x74,0x61,0x72,0x74,0x3d,0x3c,0x54,0x4d,
|
0x65,0x61,0x72,0x63,0x68,0x50,0x61,0x74,0x74,0x65,0x72,0x6e,0x45,0x6e,0x63,0x6f,
|
||||||
0x50,0x4c,0x5f,0x76,0x61,0x72,0x20,0x73,0x74,0x61,0x72,0x74,0x3e,0x26,0x65,0x6e,
|
0x64,0x65,0x64,0x3e,0x26,0x73,0x74,0x61,0x72,0x74,0x3d,0x3c,0x54,0x4d,0x50,0x4c,
|
||||||
0x64,0x3d,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,0x20,0x65,0x6e,0x64,0x3e,
|
0x5f,0x76,0x61,0x72,0x20,0x73,0x74,0x61,0x72,0x74,0x3e,0x26,0x65,0x6e,0x64,0x3d,
|
||||||
0x22,0x3e,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,0x20,0x6c,0x61,0x62,0x65,
|
0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,0x20,0x65,0x6e,0x64,0x3e,0x22,0x3e,
|
||||||
0x6c,0x3e,0x3c,0x2f,0x61,0x3e,0x3c,0x2f,0x6c,0x69,0x3e,0x0a,0x20,0x20,0x20,0x20,
|
0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,0x20,0x6c,0x61,0x62,0x65,0x6c,0x3e,
|
||||||
0x20,0x20,0x3c,0x2f,0x54,0x4d,0x50,0x4c,0x5f,0x4c,0x4f,0x4f,0x50,0x3e,0x0a,0x20,
|
0x3c,0x2f,0x61,0x3e,0x3c,0x2f,0x6c,0x69,0x3e,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||||
0x20,0x20,0x20,0x20,0x20,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x69,0x66,0x20,0x28,0x72,
|
0x3c,0x2f,0x54,0x4d,0x50,0x4c,0x5f,0x4c,0x4f,0x4f,0x50,0x3e,0x0a,0x20,0x20,0x20,
|
||||||
0x65,0x73,0x75,0x6c,0x74,0x4c,0x61,0x73,0x74,0x50,0x61,0x67,0x65,0x53,0x74,0x61,
|
0x20,0x20,0x20,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x69,0x66,0x20,0x28,0x72,0x65,0x73,
|
||||||
0x72,0x74,0x3e,0x30,0x29,0x3e,0x0a,0x09,0x3c,0x6c,0x69,0x3e,0x3c,0x61,0x20,0x68,
|
0x75,0x6c,0x74,0x4c,0x61,0x73,0x74,0x50,0x61,0x67,0x65,0x53,0x74,0x61,0x72,0x74,
|
||||||
0x72,0x65,0x66,0x3d,0x22,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,0x20,0x73,
|
0x3e,0x30,0x29,0x3e,0x0a,0x09,0x3c,0x6c,0x69,0x3e,0x3c,0x61,0x20,0x68,0x72,0x65,
|
||||||
0x65,0x61,0x72,0x63,0x68,0x50,0x72,0x6f,0x74,0x6f,0x63,0x6f,0x6c,0x50,0x72,0x65,
|
0x66,0x3d,0x22,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,0x20,0x73,0x65,0x61,
|
||||||
0x66,0x69,0x78,0x3e,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x3d,0x3c,0x54,0x4d,0x50,
|
0x72,0x63,0x68,0x50,0x72,0x6f,0x74,0x6f,0x63,0x6f,0x6c,0x50,0x72,0x65,0x66,0x69,
|
||||||
0x4c,0x5f,0x76,0x61,0x72,0x20,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x49,0x64,0x3e,
|
0x78,0x3e,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x3d,0x3c,0x54,0x4d,0x50,0x4c,0x5f,
|
||||||
0x26,0x70,0x61,0x74,0x74,0x65,0x72,0x6e,0x3d,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,
|
0x76,0x61,0x72,0x20,0x63,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x49,0x64,0x3e,0x26,0x70,
|
||||||
0x61,0x72,0x20,0x73,0x65,0x61,0x72,0x63,0x68,0x50,0x61,0x74,0x74,0x65,0x72,0x6e,
|
0x61,0x74,0x74,0x65,0x72,0x6e,0x3d,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,
|
||||||
0x3e,0x26,0x73,0x74,0x61,0x72,0x74,0x3d,0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,
|
0x20,0x73,0x65,0x61,0x72,0x63,0x68,0x50,0x61,0x74,0x74,0x65,0x72,0x6e,0x45,0x6e,
|
||||||
0x72,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x4c,0x61,0x73,0x74,0x50,0x61,0x67,0x65,
|
0x63,0x6f,0x64,0x65,0x64,0x3e,0x26,0x73,0x74,0x61,0x72,0x74,0x3d,0x3c,0x54,0x4d,
|
||||||
0x53,0x74,0x61,0x72,0x74,0x3e,0x26,0x65,0x6e,0x64,0x3d,0x3c,0x54,0x4d,0x50,0x4c,
|
0x50,0x4c,0x5f,0x76,0x61,0x72,0x20,0x72,0x65,0x73,0x75,0x6c,0x74,0x4c,0x61,0x73,
|
||||||
0x5f,0x76,0x61,0x72,0x20,0x28,0x72,0x65,0x73,0x75,0x6c,0x74,0x4c,0x61,0x73,0x74,
|
0x74,0x50,0x61,0x67,0x65,0x53,0x74,0x61,0x72,0x74,0x3e,0x26,0x65,0x6e,0x64,0x3d,
|
||||||
0x50,0x61,0x67,0x65,0x53,0x74,0x61,0x72,0x74,0x2b,0x72,0x65,0x73,0x75,0x6c,0x74,
|
0x3c,0x54,0x4d,0x50,0x4c,0x5f,0x76,0x61,0x72,0x20,0x28,0x72,0x65,0x73,0x75,0x6c,
|
||||||
0x52,0x61,0x6e,0x67,0x65,0x29,0x3e,0x22,0x3e,0xe2,0x96,0xb6,0x3c,0x2f,0x61,0x3e,
|
0x74,0x4c,0x61,0x73,0x74,0x50,0x61,0x67,0x65,0x53,0x74,0x61,0x72,0x74,0x2b,0x72,
|
||||||
0x3c,0x2f,0x6c,0x69,0x3e,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x3c,0x2f,0x54,0x4d,
|
0x65,0x73,0x75,0x6c,0x74,0x52,0x61,0x6e,0x67,0x65,0x29,0x3e,0x22,0x3e,0xe2,0x96,
|
||||||
0x50,0x4c,0x5f,0x69,0x66,0x3e,0x0a,0x20,0x20,0x20,0x20,0x3c,0x2f,0x75,0x6c,0x3e,
|
0xb6,0x3c,0x2f,0x61,0x3e,0x3c,0x2f,0x6c,0x69,0x3e,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||||
0x20,0x0a,0x20,0x3c,0x2f,0x64,0x69,0x76,0x3e,0x0a,0x3c,0x2f,0x62,0x6f,0x64,0x79,
|
0x20,0x3c,0x2f,0x54,0x4d,0x50,0x4c,0x5f,0x69,0x66,0x3e,0x0a,0x20,0x20,0x20,0x20,
|
||||||
0x3e,0x0a,0x3c,0x2f,0x68,0x74,0x6d,0x6c,0x3e,0x0a
|
0x3c,0x2f,0x75,0x6c,0x3e,0x20,0x0a,0x20,0x3c,0x2f,0x64,0x69,0x76,0x3e,0x0a,0x3c,
|
||||||
|
0x2f,0x62,0x6f,0x64,0x79,0x3e,0x0a,0x3c,0x2f,0x68,0x74,0x6d,0x6c,0x3e,0x0a
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned char server_taskbar_html_part[]={
|
const unsigned char server_taskbar_html_part[]={
|
||||||
|
|
|
@ -133,4 +133,60 @@ void kiwix::stringReplacement(std::string& str, const std::string& oldStr, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Urlencode
|
||||||
|
//based on javascript encodeURIComponent()
|
||||||
|
|
||||||
|
std::string char2hex( char dec )
|
||||||
|
{
|
||||||
|
char dig1 = (dec&0xF0)>>4;
|
||||||
|
char dig2 = (dec&0x0F);
|
||||||
|
if ( 0<= dig1 && dig1<= 9) dig1+=48; //0,48inascii
|
||||||
|
if (10<= dig1 && dig1<=15) dig1+=97-10; //a,97inascii
|
||||||
|
if ( 0<= dig2 && dig2<= 9) dig2+=48;
|
||||||
|
if (10<= dig2 && dig2<=15) dig2+=97-10;
|
||||||
|
|
||||||
|
std::string r;
|
||||||
|
r.append( &dig1, 1);
|
||||||
|
r.append( &dig2, 1);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string kiwix::urlEncode(const std::string &c) {
|
||||||
|
std::string escaped="";
|
||||||
|
int max = c.length();
|
||||||
|
for(int i=0; i<max; i++)
|
||||||
|
{
|
||||||
|
if ( (48 <= c[i] && c[i] <= 57) ||//0-9
|
||||||
|
(65 <= c[i] && c[i] <= 90) ||//abc...xyz
|
||||||
|
(97 <= c[i] && c[i] <= 122) || //ABC...XYZ
|
||||||
|
(c[i]=='~' || c[i]=='!' || c[i]=='*' || c[i]=='(' || c[i]==')' || c[i]=='\'')
|
||||||
|
)
|
||||||
|
{
|
||||||
|
escaped.append( &c[i], 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
escaped.append("%");
|
||||||
|
escaped.append( char2hex(c[i]) );//converts char 255 to string "ff"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return escaped;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string kiwix::urlDecode(const std::string &SRC) {
|
||||||
|
std::string ret;
|
||||||
|
char ch;
|
||||||
|
int i, ii;
|
||||||
|
for (i=0; i<SRC.length(); i++) {
|
||||||
|
if (int(SRC[i])==37) {
|
||||||
|
sscanf(SRC.substr(i+1,2).c_str(), "%x", &ii);
|
||||||
|
ch=static_cast<char>(ii);
|
||||||
|
ret+=ch;
|
||||||
|
i=i+2;
|
||||||
|
} else {
|
||||||
|
ret+=SRC[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,9 @@ namespace kiwix {
|
||||||
std::string lcFirst(const std::string &word);
|
std::string lcFirst(const std::string &word);
|
||||||
|
|
||||||
void stringReplacement(std::string& str, const std::string& oldStr, const std::string& newStr);
|
void stringReplacement(std::string& str, const std::string& oldStr, const std::string& newStr);
|
||||||
|
|
||||||
|
std::string urlEncode(const std::string &c);
|
||||||
|
std::string urlDecode(const std::string &c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -115,13 +115,13 @@
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<ul>
|
<ul>
|
||||||
<TMPL_if (resultLastPageStart>0)>
|
<TMPL_if (resultLastPageStart>0)>
|
||||||
<li><a href="<TMPL_var searchProtocolPrefix>content=<TMPL_var contentId>&pattern=<TMPL_var searchPattern>&start=0&end=<TMPL_var resultRange>">◀</a></li>
|
<li><a href="<TMPL_var searchProtocolPrefix>content=<TMPL_var contentId>&pattern=<TMPL_var searchPatternEncoded>&start=0&end=<TMPL_var resultRange>">◀</a></li>
|
||||||
</TMPL_if>
|
</TMPL_if>
|
||||||
<TMPL_loop pages>
|
<TMPL_loop pages>
|
||||||
<li><a <TMPL_if selected>class="selected"</TMPL_if> href="<TMPL_var searchProtocolPrefix>content=<TMPL_var contentId>&pattern=<TMPL_var searchPattern>&start=<TMPL_var start>&end=<TMPL_var end>"><TMPL_var label></a></li>
|
<li><a <TMPL_if selected>class="selected"</TMPL_if> href="<TMPL_var searchProtocolPrefix>content=<TMPL_var contentId>&pattern=<TMPL_var searchPatternEncoded>&start=<TMPL_var start>&end=<TMPL_var end>"><TMPL_var label></a></li>
|
||||||
</TMPL_LOOP>
|
</TMPL_LOOP>
|
||||||
<TMPL_if (resultLastPageStart>0)>
|
<TMPL_if (resultLastPageStart>0)>
|
||||||
<li><a href="<TMPL_var searchProtocolPrefix>content=<TMPL_var contentId>&pattern=<TMPL_var searchPattern>&start=<TMPL_var resultLastPageStart>&end=<TMPL_var (resultLastPageStart+resultRange)>">▶</a></li>
|
<li><a href="<TMPL_var searchProtocolPrefix>content=<TMPL_var contentId>&pattern=<TMPL_var searchPatternEncoded>&start=<TMPL_var resultLastPageStart>&end=<TMPL_var (resultLastPageStart+resultRange)>">▶</a></li>
|
||||||
</TMPL_if>
|
</TMPL_if>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue