mirror of https://github.com/aria2/aria2
Fix json::decodeGetParams when compiled with recent Apple clang
parent
270f429838
commit
9da17424c6
87
src/json.cc
87
src/json.cc
|
@ -101,51 +101,52 @@ decodeGetParams(const std::string& query)
|
||||||
{
|
{
|
||||||
std::string jsonRequest;
|
std::string jsonRequest;
|
||||||
std::string callback;
|
std::string callback;
|
||||||
if(!query.empty() && query[0] == '?') {
|
if (query.empty() || query[0] != '?') {
|
||||||
Scip method;
|
return JsonGetParam(jsonRequest, callback);
|
||||||
Scip id;
|
}
|
||||||
Scip params;
|
|
||||||
std::vector<Scip> getParams;
|
Scip method = std::make_pair(query.end(), query.end());
|
||||||
util::splitIter(query.begin()+1, query.end(), std::back_inserter(getParams),
|
Scip id = std::make_pair(query.end(), query.end());
|
||||||
'&');
|
Scip params = std::make_pair(query.end(), query.end());
|
||||||
for(std::vector<Scip>::const_iterator i =
|
std::vector<Scip> getParams;
|
||||||
getParams.begin(), eoi = getParams.end(); i != eoi; ++i) {
|
util::splitIter(query.begin()+1, query.end(), std::back_inserter(getParams),
|
||||||
if(util::startsWith((*i).first, (*i).second, "method=")) {
|
'&');
|
||||||
method.first = (*i).first+7;
|
for (const auto& i : getParams) {
|
||||||
method.second = (*i).second;
|
if(util::startsWith(i.first, i.second, "method=")) {
|
||||||
} else if(util::startsWith((*i).first, (*i).second, "id=")) {
|
method.first = i.first+7;
|
||||||
id.first = (*i).first+3;
|
method.second = i.second;
|
||||||
id.second = (*i).second;
|
} else if(util::startsWith(i.first, i.second, "id=")) {
|
||||||
} else if(util::startsWith((*i).first, (*i).second, "params=")) {
|
id.first = i.first+3;
|
||||||
params.first = (*i).first+7;
|
id.second = i.second;
|
||||||
params.second = (*i).second;
|
} else if(util::startsWith(i.first, i.second, "params=")) {
|
||||||
} else if(util::startsWith((*i).first, (*i).second, "jsoncallback=")) {
|
params.first = i.first+7;
|
||||||
callback.assign((*i).first+13, (*i).second);
|
params.second = i.second;
|
||||||
}
|
} else if(util::startsWith(i.first, i.second, "jsoncallback=")) {
|
||||||
|
callback.assign(i.first+13, i.second);
|
||||||
}
|
}
|
||||||
std::string decparam = util::percentDecode(params.first, params.second);
|
}
|
||||||
std::string jsonParam = base64::decode(decparam.begin(), decparam.end());
|
std::string decparam = util::percentDecode(params.first, params.second);
|
||||||
if(method.first == method.second && id.first == id.second) {
|
std::string jsonParam = base64::decode(decparam.begin(), decparam.end());
|
||||||
// Assume batch call.
|
if(method.first == method.second && id.first == id.second) {
|
||||||
jsonRequest = jsonParam;
|
// Assume batch call.
|
||||||
} else {
|
jsonRequest = jsonParam;
|
||||||
jsonRequest = "{";
|
} else {
|
||||||
if(method.first != method.second) {
|
jsonRequest = "{";
|
||||||
jsonRequest += "\"method\":\"";
|
if(method.first != method.second) {
|
||||||
jsonRequest.append(method.first, method.second);
|
jsonRequest += "\"method\":\"";
|
||||||
jsonRequest += "\"";
|
jsonRequest.append(method.first, method.second);
|
||||||
}
|
jsonRequest += "\"";
|
||||||
if(id.first != id.second) {
|
|
||||||
jsonRequest += ",\"id\":\"";
|
|
||||||
jsonRequest.append(id.first, id.second);
|
|
||||||
jsonRequest += "\"";
|
|
||||||
}
|
|
||||||
if(params.first != params.second) {
|
|
||||||
jsonRequest += ",\"params\":";
|
|
||||||
jsonRequest += jsonParam;
|
|
||||||
}
|
|
||||||
jsonRequest += "}";
|
|
||||||
}
|
}
|
||||||
|
if(id.first != id.second) {
|
||||||
|
jsonRequest += ",\"id\":\"";
|
||||||
|
jsonRequest.append(id.first, id.second);
|
||||||
|
jsonRequest += "\"";
|
||||||
|
}
|
||||||
|
if(params.first != params.second) {
|
||||||
|
jsonRequest += ",\"params\":";
|
||||||
|
jsonRequest += jsonParam;
|
||||||
|
}
|
||||||
|
jsonRequest += "}";
|
||||||
}
|
}
|
||||||
return JsonGetParam(jsonRequest, callback);
|
return JsonGetParam(jsonRequest, callback);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue