mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 15:02:56 +02:00
nhttpd: don't decode URL parameters multiple times
This commit is contained in:
@@ -1569,7 +1569,7 @@ void CControlAPI::StartPluginCGI(CyhookHandler *hh)
|
||||
if (hh->ParamList["name"] != "")
|
||||
{
|
||||
pluginname = hh->ParamList["name"];
|
||||
pluginname=decodeString(pluginname);
|
||||
//pluginname=decodeString(pluginname);
|
||||
NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::EVT_START_PLUGIN,
|
||||
CEventServer::INITID_HTTPD,
|
||||
(void *) pluginname.c_str(),
|
||||
|
@@ -214,7 +214,7 @@ std::string decodeString(std::string encodedString) {
|
||||
return result;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// Encode URLEncoded std::string
|
||||
// HTMLEncode std::string
|
||||
//-----------------------------------------------------------------------------
|
||||
std::string encodeString(std::string decodedString) {
|
||||
unsigned int len = sizeof(char) * decodedString.length() * 5 + 1;
|
||||
|
@@ -160,6 +160,7 @@ bool CWebserverRequest::ParseParams(std::string param_string) {
|
||||
if (!ySplitStringExact(param_string, "&", param, param_string))
|
||||
ende = true;
|
||||
if (ySplitStringExact(param, "=", name, value)) {
|
||||
name = decodeString(name);
|
||||
value = trim(decodeString(value));
|
||||
if (ParameterList[name].empty())
|
||||
ParameterList[name] = value;
|
||||
@@ -168,11 +169,10 @@ bool CWebserverRequest::ParseParams(std::string param_string) {
|
||||
ParameterList[name] += value;
|
||||
}
|
||||
}
|
||||
else
|
||||
name = trim(decodeString(name));
|
||||
number = string_printf("%d", ParameterList.size() + 1);
|
||||
log_level_printf(7, "ParseParams: name: %s value: %s\n", name.c_str(), value.c_str());
|
||||
if(value.empty()){
|
||||
name = trim(decodeString(name));
|
||||
}
|
||||
ParameterList[number] = name;
|
||||
}
|
||||
return true;
|
||||
@@ -212,19 +212,24 @@ bool CWebserverRequest::ParseHeader(std::string header) {
|
||||
// query data is splitted and stored in ParameterList
|
||||
//-----------------------------------------------------------------------------
|
||||
void CWebserverRequest::analyzeURL(std::string url) {
|
||||
std::string fullurl = "";
|
||||
if(!ParameterList.empty())
|
||||
ParameterList.clear();
|
||||
|
||||
// URI decode
|
||||
url = trim(url, "\r\n"); // non-HTTP-Standard: allow \r or \n in URL. Delete it.
|
||||
UrlData["fullurl"] = url;
|
||||
fullurl = decodeString(url);
|
||||
fullurl = trim(fullurl, "\r\n"); // non-HTTP-Standard: allow \r or \n in URL. Delete it.
|
||||
UrlData["fullurl"] = fullurl;
|
||||
|
||||
// split Params
|
||||
if (ySplitString(url, "?", UrlData["url"], UrlData["paramstring"])){ // split pure URL and all Params
|
||||
UrlData["url"] = decodeString(UrlData["url"]);
|
||||
ParseParams( UrlData["paramstring"]); // split params to ParameterList
|
||||
}else{
|
||||
// No Params
|
||||
url = decodeString(url);
|
||||
UrlData["url"] = url;
|
||||
UrlData["url"] = fullurl;
|
||||
}
|
||||
|
||||
if (!ySplitStringLast(UrlData["url"], "/", UrlData["path"],
|
||||
UrlData["filename"])) {
|
||||
UrlData["path"] = "/"; // Set "/" if not contained
|
||||
|
Reference in New Issue
Block a user