From fc26f08af223161ce7437bd1815f8a7e4e4451ba Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 22 Feb 2013 21:23:59 +0900 Subject: [PATCH] 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. --- src/shrpx_config.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/shrpx_config.cc b/src/shrpx_config.cc index 3de8ccb9..b22f8a29 100644 --- a/src/shrpx_config.cc +++ b/src/shrpx_config.cc @@ -328,9 +328,13 @@ int parse_config(const char *opt, const char *optarg) std::string val; if(u.field_set & UF_USERINFO) { http::copy_url_component(val, &u, UF_USERINFO, optarg); - val = util::percentDecode(val.begin(), val.end()); - set_config_str(&mod_config()->downstream_http_proxy_userinfo, - val.c_str()); + // Surprisingly, u.field_set & UF_USERINFO is nonzero even if + // userinfo component is empty string. + 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) { http::copy_url_component(val, &u, UF_HOST, optarg);