mirror of https://github.com/kiwix/libkiwix.git
FIXED: kiwix-serve XSS attack vulnerability (#763)
This commit is contained in:
parent
191d37a105
commit
8287a64172
|
@ -180,7 +180,7 @@ namespace kiwix {
|
||||||
oData["pages"] = pagesCDT;
|
oData["pages"] = pagesCDT;
|
||||||
|
|
||||||
oData["count"] = kiwix::beautifyInteger(this->estimatedResultCount);
|
oData["count"] = kiwix::beautifyInteger(this->estimatedResultCount);
|
||||||
oData["searchPattern"] = this->searchPattern;
|
oData["searchPattern"] = kiwix::encodeDiples(this->searchPattern);
|
||||||
oData["searchPatternEncoded"] = urlEncode(this->searchPattern);
|
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);
|
||||||
|
|
|
@ -104,6 +104,14 @@ void kiwix::stringReplacement(std::string& str, const std::string& oldStr, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Encode string to avoid XSS attacks */
|
||||||
|
std::string kiwix::encodeDiples(const std::string& str) {
|
||||||
|
std::string result = str;
|
||||||
|
kiwix::stringReplacement(result, "<", "<");
|
||||||
|
kiwix::stringReplacement(result, ">", ">");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Urlencode
|
// Urlencode
|
||||||
//based on javascript encodeURIComponent()
|
//based on javascript encodeURIComponent()
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ namespace kiwix {
|
||||||
void printStringInHexadecimal(const char *s);
|
void printStringInHexadecimal(const char *s);
|
||||||
void printStringInHexadecimal(UnicodeString s);
|
void printStringInHexadecimal(UnicodeString s);
|
||||||
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 encodeDiples(const std::string& str);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue