From: Andreas Unterkircher Date: Mon, 20 Apr 2020 08:28:38 +0000 (+0200) Subject: src/rgw/rgw_url.cc, also cope with a vhost appended to a AMQP-URL X-Git-Tag: v17.0.0~2264^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a984d2a08c013c7cf78a25234d9fafb78c6cdc9a;p=ceph.git src/rgw/rgw_url.cc, also cope with a vhost appended to a AMQP-URL Signed-off-by: Yuval Lifshitz Fixes: https://tracker.ceph.com/issues/45269 --- diff --git a/src/rgw/rgw_url.cc b/src/rgw/rgw_url.cc index 24c25378239ff..62b003c49c298 100644 --- a/src/rgw/rgw_url.cc +++ b/src/rgw/rgw_url.cc @@ -14,32 +14,33 @@ namespace { const std::string schema_re = "([[:alpha:]]+:\\/\\/)"; const std::string user_pass_re = "(([^:\\s]+):([^@\\s]+)@)?"; const std::string host_port_re = "([[:alnum:].:-]+)"; + const std::string vhost_re = "(/[[:print:]]+)?"; } bool parse_url_authority(const std::string& url, std::string& host, std::string& user, std::string& password) { - const std::string re = schema_re + user_pass_re + host_port_re; + const std::string re = schema_re + user_pass_re + host_port_re + vhost_re; const std::regex url_regex(re, std::regex::icase); std::smatch url_match_result; if (std::regex_match(url, url_match_result, url_regex)) { host = url_match_result[HOST_GROUP_IDX]; - user = url_match_result[USER_GROUP_IDX]; + user = url_match_result[USER_GROUP_IDX]; password = url_match_result[PASSWORD_GROUP_IDX]; - return true; + return true; } return false; } bool parse_url_userinfo(const std::string& url, std::string& user, std::string& password) { - const std::string re = schema_re + user_pass_re + host_port_re; + const std::string re = schema_re + user_pass_re + host_port_re + vhost_re; const std::regex url_regex(re); std::smatch url_match_result; if (std::regex_match(url, url_match_result, url_regex)) { - user = url_match_result[USER_GROUP_IDX]; + user = url_match_result[USER_GROUP_IDX]; password = url_match_result[PASSWORD_GROUP_IDX]; - return true; + return true; } return false;