shrpx: Fix Proxy-Authorization is alwasy sent even if userinfo is empty

Surprisingly, field_set & UF_USERINFO is nonzero even if userinfo
component is empty string.
This commit is contained in:
Tatsuhiro Tsujikawa 2013-02-22 21:23:59 +09:00
parent 78523c6701
commit fc26f08af2
1 changed files with 7 additions and 3 deletions

View File

@ -328,9 +328,13 @@ int parse_config(const char *opt, const char *optarg)
std::string val; std::string val;
if(u.field_set & UF_USERINFO) { if(u.field_set & UF_USERINFO) {
http::copy_url_component(val, &u, UF_USERINFO, optarg); http::copy_url_component(val, &u, UF_USERINFO, optarg);
val = util::percentDecode(val.begin(), val.end()); // Surprisingly, u.field_set & UF_USERINFO is nonzero even if
set_config_str(&mod_config()->downstream_http_proxy_userinfo, // userinfo component is empty string.
val.c_str()); if(!val.empty()) {
val = util::percentDecode(val.begin(), val.end());
set_config_str(&mod_config()->downstream_http_proxy_userinfo,
val.c_str());
}
} }
if(u.field_set & UF_HOST) { if(u.field_set & UF_HOST) {
http::copy_url_component(val, &u, UF_HOST, optarg); http::copy_url_component(val, &u, UF_HOST, optarg);