mirror of https://github.com/aria2/aria2
Made const char[] static
parent
d17ea2837b
commit
226480ad60
|
@ -83,12 +83,12 @@ HttpConnection::~HttpConnection() {}
|
||||||
|
|
||||||
std::string HttpConnection::eraseConfidentialInfo(const std::string& request)
|
std::string HttpConnection::eraseConfidentialInfo(const std::string& request)
|
||||||
{
|
{
|
||||||
|
static const char A2_AUTH_HEADER[] = "Authorization: Basic";
|
||||||
|
static const char A2_PROXY_AUTH_HEADER[] = "Proxy-Authorization: Basic";
|
||||||
std::istringstream istr(request);
|
std::istringstream istr(request);
|
||||||
std::string result;
|
std::string result;
|
||||||
std::string line;
|
std::string line;
|
||||||
while(getline(istr, line)) {
|
while(getline(istr, line)) {
|
||||||
const char A2_AUTH_HEADER[] = "Authorization: Basic";
|
|
||||||
const char A2_PROXY_AUTH_HEADER[] = "Proxy-Authorization: Basic";
|
|
||||||
if(util::startsWith(line.begin(), line.end(),
|
if(util::startsWith(line.begin(), line.end(),
|
||||||
A2_AUTH_HEADER, vend(A2_AUTH_HEADER)-1)) {
|
A2_AUTH_HEADER, vend(A2_AUTH_HEADER)-1)) {
|
||||||
result += "Authorization: Basic ********\n";
|
result += "Authorization: Basic ********\n";
|
||||||
|
|
|
@ -441,8 +441,8 @@ bool HttpRequest::conditionalRequest() const
|
||||||
if(!ifModSinceHeader_.empty()) {
|
if(!ifModSinceHeader_.empty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const char A2_IF_MOD_SINCE[] = "if-modified-since";
|
static const char A2_IF_MOD_SINCE[] = "if-modified-since";
|
||||||
const char A2_IF_NONE_MATCH[] = "if-none-match";
|
static const char A2_IF_NONE_MATCH[] = "if-none-match";
|
||||||
for(std::vector<std::string>::const_iterator i = headers_.begin(),
|
for(std::vector<std::string>::const_iterator i = headers_.begin(),
|
||||||
eoi = headers_.end(); i != eoi; ++i) {
|
eoi = headers_.end(); i != eoi; ++i) {
|
||||||
std::string hd = util::toLower(*i);
|
std::string hd = util::toLower(*i);
|
||||||
|
|
|
@ -221,7 +221,7 @@ bool HttpServer::authenticate()
|
||||||
}
|
}
|
||||||
std::pair<Scip, Scip> p;
|
std::pair<Scip, Scip> p;
|
||||||
util::divide(p, authHeader.begin(), authHeader.end(), ' ');
|
util::divide(p, authHeader.begin(), authHeader.end(), ' ');
|
||||||
const char A2_AUTHMETHOD[] = "Basic";
|
static const char A2_AUTHMETHOD[] = "Basic";
|
||||||
if(!util::streq(p.first.first, p.first.second,
|
if(!util::streq(p.first.first, p.first.second,
|
||||||
A2_AUTHMETHOD, vend(A2_AUTHMETHOD)-1)) {
|
A2_AUTHMETHOD, vend(A2_AUTHMETHOD)-1)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
14
src/Netrc.cc
14
src/Netrc.cc
|
@ -154,15 +154,15 @@ void Netrc::parse(const std::string& path)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std::vector<Scip> tokens;
|
std::vector<Scip> tokens;
|
||||||
const char A2_DELIMS[] = " \t";
|
static const char A2_DELIMS[] = " \t";
|
||||||
util::splitIterM(&buf[0], &buf[len], std::back_inserter(tokens),
|
util::splitIterM(&buf[0], &buf[len], std::back_inserter(tokens),
|
||||||
A2_DELIMS, vend(A2_DELIMS)-1, true);
|
A2_DELIMS, vend(A2_DELIMS)-1, true);
|
||||||
const char A2_MACHINE[] = "machine";
|
static const char A2_MACHINE[] = "machine";
|
||||||
const char A2_DEFAULT[] = "default";
|
static const char A2_DEFAULT[] = "default";
|
||||||
const char A2_LOGIN[] = "login";
|
static const char A2_LOGIN[] = "login";
|
||||||
const char A2_PASSWORD[] = "password";
|
static const char A2_PASSWORD[] = "password";
|
||||||
const char A2_ACCOUNT[] = "account";
|
static const char A2_ACCOUNT[] = "account";
|
||||||
const char A2_MACDEF[] = "macdef";
|
static const char A2_MACDEF[] = "macdef";
|
||||||
for(std::vector<Scip>::const_iterator iter = tokens.begin(),
|
for(std::vector<Scip>::const_iterator iter = tokens.begin(),
|
||||||
eoi = tokens.end(); iter != eoi; ++iter) {
|
eoi = tokens.end(); iter != eoi; ++iter) {
|
||||||
if(state == GET_TOKEN) {
|
if(state == GET_TOKEN) {
|
||||||
|
|
|
@ -87,7 +87,7 @@ bool parseNsCookie
|
||||||
// aria2 treats expiryTime == 0 means session cookie.
|
// aria2 treats expiryTime == 0 means session cookie.
|
||||||
cookie.setPersistent(expiryTime != 0);
|
cookie.setPersistent(expiryTime != 0);
|
||||||
cookie.setDomain(vs[0].first, vs[0].second);
|
cookie.setDomain(vs[0].first, vs[0].second);
|
||||||
const char C_TRUE[] = "TRUE";
|
static const char C_TRUE[] = "TRUE";
|
||||||
cookie.setHostOnly(util::isNumericHost(cookie.getDomain()) ||
|
cookie.setHostOnly(util::isNumericHost(cookie.getDomain()) ||
|
||||||
!util::streq(vs[1].first, vs[1].second,
|
!util::streq(vs[1].first, vs[1].second,
|
||||||
C_TRUE, vend(C_TRUE)-1));
|
C_TRUE, vend(C_TRUE)-1));
|
||||||
|
|
|
@ -521,7 +521,7 @@ HttpProxyUserOptionHandler::HttpProxyUserOptionHandler
|
||||||
void HttpProxyUserOptionHandler::parseArg
|
void HttpProxyUserOptionHandler::parseArg
|
||||||
(Option& option, const std::string& optarg)
|
(Option& option, const std::string& optarg)
|
||||||
{
|
{
|
||||||
const char A2_USER[] = "-user";
|
static const char A2_USER[] = "-user";
|
||||||
size_t kLen = strlen(pref_->k);
|
size_t kLen = strlen(pref_->k);
|
||||||
if(util::endsWith(pref_->k, pref_->k+kLen, A2_USER, vend(A2_USER)-1)) {
|
if(util::endsWith(pref_->k, pref_->k+kLen, A2_USER, vend(A2_USER)-1)) {
|
||||||
const Pref* proxyPref = option::k2p(std::string(pref_->k, kLen-5));
|
const Pref* proxyPref = option::k2p(std::string(pref_->k, kLen-5));
|
||||||
|
@ -565,7 +565,7 @@ HttpProxyPasswdOptionHandler::HttpProxyPasswdOptionHandler
|
||||||
void HttpProxyPasswdOptionHandler::parseArg
|
void HttpProxyPasswdOptionHandler::parseArg
|
||||||
(Option& option, const std::string& optarg)
|
(Option& option, const std::string& optarg)
|
||||||
{
|
{
|
||||||
const char A2_PASSWD[] = "-passwd";
|
static const char A2_PASSWD[] = "-passwd";
|
||||||
size_t kLen = strlen(pref_->k);
|
size_t kLen = strlen(pref_->k);
|
||||||
if(util::endsWith(pref_->k, pref_->k+kLen, A2_PASSWD, vend(A2_PASSWD)-1)) {
|
if(util::endsWith(pref_->k, pref_->k+kLen, A2_PASSWD, vend(A2_PASSWD)-1)) {
|
||||||
const Pref* proxyPref = option::k2p(std::string(pref_->k, kLen-7));
|
const Pref* proxyPref = option::k2p(std::string(pref_->k, kLen-7));
|
||||||
|
@ -617,9 +617,9 @@ void HttpProxyOptionHandler::parseArg(Option& option, const std::string& optarg)
|
||||||
} else {
|
} else {
|
||||||
Request req;
|
Request req;
|
||||||
std::string uri;
|
std::string uri;
|
||||||
const char A2_HTTP[] = "http://";
|
static const char A2_HTTP[] = "http://";
|
||||||
const char A2_HTTPS[] = "https://";
|
static const char A2_HTTPS[] = "https://";
|
||||||
const char A2_FTP[] = "ftp://";
|
static const char A2_FTP[] = "ftp://";
|
||||||
if(util::startsWith(optarg.begin(), optarg.end(),
|
if(util::startsWith(optarg.begin(), optarg.end(),
|
||||||
A2_HTTP, vend(A2_HTTP)-1) ||
|
A2_HTTP, vend(A2_HTTP)-1) ||
|
||||||
util::startsWith(optarg.begin(), optarg.end(),
|
util::startsWith(optarg.begin(), optarg.end(),
|
||||||
|
|
|
@ -875,7 +875,7 @@ SharedHandle<TorrentAttribute> parseMagnet(const std::string& magnet)
|
||||||
}
|
}
|
||||||
SharedHandle<TorrentAttribute> attrs(new TorrentAttribute());
|
SharedHandle<TorrentAttribute> attrs(new TorrentAttribute());
|
||||||
std::string infoHash;
|
std::string infoHash;
|
||||||
const char A2_URN_BTIH[] = "urn:btih:";
|
static const char A2_URN_BTIH[] = "urn:btih:";
|
||||||
for(List::ValueType::const_iterator xtiter = xts->begin(),
|
for(List::ValueType::const_iterator xtiter = xts->begin(),
|
||||||
eoi = xts->end(); xtiter != eoi && infoHash.empty(); ++xtiter) {
|
eoi = xts->end(); xtiter != eoi && infoHash.empty(); ++xtiter) {
|
||||||
const String* xt = downcast<String>(*xtiter);
|
const String* xt = downcast<String>(*xtiter);
|
||||||
|
|
|
@ -545,10 +545,10 @@ decodeGetParams(const std::string& query)
|
||||||
std::vector<Scip> getParams;
|
std::vector<Scip> getParams;
|
||||||
util::splitIter(query.begin()+1, query.end(), std::back_inserter(getParams),
|
util::splitIter(query.begin()+1, query.end(), std::back_inserter(getParams),
|
||||||
'&');
|
'&');
|
||||||
const char A2_METHOD[] = "method=";
|
static const char A2_METHOD[] = "method=";
|
||||||
const char A2_ID[] = "id=";
|
static const char A2_ID[] = "id=";
|
||||||
const char A2_PARAMS[] = "params=";
|
static const char A2_PARAMS[] = "params=";
|
||||||
const char A2_JSONCB[] = "jsoncallback=";
|
static const char A2_JSONCB[] = "jsoncallback=";
|
||||||
for(std::vector<Scip>::const_iterator i =
|
for(std::vector<Scip>::const_iterator i =
|
||||||
getParams.begin(), eoi = getParams.end(); i != eoi; ++i) {
|
getParams.begin(), eoi = getParams.end(); i != eoi; ++i) {
|
||||||
if(util::startsWith((*i).first, (*i).second,
|
if(util::startsWith((*i).first, (*i).second,
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace magnet {
|
||||||
SharedHandle<Dict> parse(const std::string& magnet)
|
SharedHandle<Dict> parse(const std::string& magnet)
|
||||||
{
|
{
|
||||||
SharedHandle<Dict> dict;
|
SharedHandle<Dict> dict;
|
||||||
const char A2_MSGNET[] = "magnet:?";
|
static const char A2_MSGNET[] = "magnet:?";
|
||||||
if(!util::startsWith(magnet.begin(), magnet.end(),
|
if(!util::startsWith(magnet.begin(), magnet.end(),
|
||||||
A2_MSGNET, vend(A2_MSGNET)-1)) {
|
A2_MSGNET, vend(A2_MSGNET)-1)) {
|
||||||
return dict;
|
return dict;
|
||||||
|
|
|
@ -115,7 +115,7 @@ void option_processing(Option& op, std::vector<std::string>& uris,
|
||||||
keyword = TAG_BASIC;
|
keyword = TAG_BASIC;
|
||||||
} else {
|
} else {
|
||||||
keyword = op.get(PREF_HELP);
|
keyword = op.get(PREF_HELP);
|
||||||
const char A2_HH[] = "--";
|
static const char A2_HH[] = "--";
|
||||||
if(util::startsWith(keyword.begin(), keyword.end(),
|
if(util::startsWith(keyword.begin(), keyword.end(),
|
||||||
A2_HH, vend(A2_HH)-1)) {
|
A2_HH, vend(A2_HH)-1)) {
|
||||||
keyword.erase(keyword.begin(), keyword.begin()+2);
|
keyword.erase(keyword.begin(), keyword.begin()+2);
|
||||||
|
|
32
src/util.cc
32
src/util.cc
|
@ -638,10 +638,10 @@ void parsePrioritizePieceRange
|
||||||
{
|
{
|
||||||
std::vector<size_t> indexes;
|
std::vector<size_t> indexes;
|
||||||
std::vector<Scip> parts;
|
std::vector<Scip> parts;
|
||||||
const char A2_HEAD[] = "head";
|
static const char A2_HEAD[] = "head";
|
||||||
const char A2_HEADEQ[] = "head=";
|
static const char A2_HEADEQ[] = "head=";
|
||||||
const char A2_TAIL[] = "tail";
|
static const char A2_TAIL[] = "tail";
|
||||||
const char A2_TAILEQ[] = "tail=";
|
static const char A2_TAILEQ[] = "tail=";
|
||||||
splitIter(src.begin(), src.end(), std::back_inserter(parts), ',', true);
|
splitIter(src.begin(), src.end(), std::back_inserter(parts), ',', true);
|
||||||
for(std::vector<Scip>::const_iterator i = parts.begin(),
|
for(std::vector<Scip>::const_iterator i = parts.begin(),
|
||||||
eoi = parts.end(); i != eoi; ++i) {
|
eoi = parts.end(); i != eoi; ++i) {
|
||||||
|
@ -736,7 +736,7 @@ void parseParam(OutputIterator out, const std::string& header)
|
||||||
|
|
||||||
std::string getContentDispositionFilename(const std::string& header)
|
std::string getContentDispositionFilename(const std::string& header)
|
||||||
{
|
{
|
||||||
const char A2_KEYNAME[] = "filename";
|
static const char A2_KEYNAME[] = "filename";
|
||||||
std::string filename;
|
std::string filename;
|
||||||
std::vector<std::string> params;
|
std::vector<std::string> params;
|
||||||
parseParam(std::back_inserter(params), header);
|
parseParam(std::back_inserter(params), header);
|
||||||
|
@ -801,7 +801,7 @@ std::string getContentDispositionFilename(const std::string& header)
|
||||||
}
|
}
|
||||||
std::string value =
|
std::string value =
|
||||||
percentDecode(extValues[2].first, extValues[2].second);
|
percentDecode(extValues[2].first, extValues[2].second);
|
||||||
const char A2_ISO88591[] = "iso-8859-1";
|
static const char A2_ISO88591[] = "iso-8859-1";
|
||||||
if(util::strieq(extValues[0].first, extValues[0].second,
|
if(util::strieq(extValues[0].first, extValues[0].second,
|
||||||
A2_ISO88591, vend(A2_ISO88591)-1)) {
|
A2_ISO88591, vend(A2_ISO88591)-1)) {
|
||||||
value = iso8859ToUtf8(value);
|
value = iso8859ToUtf8(value);
|
||||||
|
@ -1282,8 +1282,8 @@ void generateRandomKey(unsigned char* key)
|
||||||
// 192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
|
// 192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
|
||||||
bool inPrivateAddress(const std::string& ipv4addr)
|
bool inPrivateAddress(const std::string& ipv4addr)
|
||||||
{
|
{
|
||||||
const char A2_IP10[] = "10.";
|
static const char A2_IP10[] = "10.";
|
||||||
const char A2_IP192[] = "192.168.";
|
static const char A2_IP192[] = "192.168.";
|
||||||
if(util::startsWith(ipv4addr.begin(), ipv4addr.end(),
|
if(util::startsWith(ipv4addr.begin(), ipv4addr.end(),
|
||||||
A2_IP10, vend(A2_IP10)-1) ||
|
A2_IP10, vend(A2_IP10)-1) ||
|
||||||
util::startsWith(ipv4addr.begin(), ipv4addr.end(),
|
util::startsWith(ipv4addr.begin(), ipv4addr.end(),
|
||||||
|
@ -1318,13 +1318,13 @@ bool detectDirTraversal(const std::string& s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char A2_DS[] = "./";
|
static const char A2_DS[] = "./";
|
||||||
const char A2_DDS[] = "../";
|
static const char A2_DDS[] = "../";
|
||||||
const char A2_SD[] = "/.";
|
static const char A2_SD[] = "/.";
|
||||||
const char A2_SDD[] = "/..";
|
static const char A2_SDD[] = "/..";
|
||||||
const char A2_SDDS[] = "/../";
|
static const char A2_SDDS[] = "/../";
|
||||||
const char A2_SDS[] = "/./";
|
static const char A2_SDS[] = "/./";
|
||||||
const char A2_DD[] = "..";
|
static const char A2_DD[] = "..";
|
||||||
|
|
||||||
return s == A2STR::DOT_C ||
|
return s == A2STR::DOT_C ||
|
||||||
s == A2_DD ||
|
s == A2_DD ||
|
||||||
|
@ -1439,7 +1439,7 @@ void executeHook
|
||||||
|
|
||||||
memset(&pi, 0, sizeof (pi));
|
memset(&pi, 0, sizeof (pi));
|
||||||
|
|
||||||
const char A2_BAT[] = ".bat";
|
static const char A2_BAT[] = ".bat";
|
||||||
bool batch = util::iendsWith(command.begin(), command.end(),
|
bool batch = util::iendsWith(command.begin(), command.end(),
|
||||||
A2_BAT, vend(A2_BAT)-1);
|
A2_BAT, vend(A2_BAT)-1);
|
||||||
std::string cmdline;
|
std::string cmdline;
|
||||||
|
|
Loading…
Reference in New Issue