From: Kalpesh Pandya Date: Wed, 13 Oct 2021 19:59:06 +0000 (+0530) Subject: src/rgw: Fix for malformed url X-Git-Tag: v16.2.8~89^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F45459%2Fhead;p=ceph.git src/rgw: Fix for malformed url This PR solves: https://tracker.ceph.com/issues/52738 It is solved by making changes to rgw_url.cc A test is also added to check it's working. Signed-off-by: Kalpesh Pandya (cherry picked from commit 2916f2439eb2f62bc08c3e283b13391302b3e497) --- diff --git a/src/rgw/rgw_url.cc b/src/rgw/rgw_url.cc index 58f7b5490538..7fd4788d77c6 100644 --- a/src/rgw/rgw_url.cc +++ b/src/rgw/rgw_url.cc @@ -14,7 +14,7 @@ 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 path_re = "(/[[:print:]]+)?"; + const std::string path_re = "(/[[:print:]]*)?"; } bool parse_url_authority(const std::string& url, std::string& host, std::string& user, std::string& password) { diff --git a/src/test/rgw/test_rgw_url.cc b/src/test/rgw/test_rgw_url.cc index d38457b815d2..b61e1d595921 100644 --- a/src/test/rgw/test_rgw_url.cc +++ b/src/test/rgw/test_rgw_url.cc @@ -19,6 +19,18 @@ TEST(TestURL, SimpleAuthority) EXPECT_STREQ(host.c_str(), "example.com"); } +TEST(TestURL, SimpleAuthority_1) +{ + std::string host; + std::string user; + std::string password; + const std::string url = "http://example.com/"; + ASSERT_TRUE(parse_url_authority(url, host, user, password)); + ASSERT_TRUE(user.empty()); + ASSERT_TRUE(password.empty()); + EXPECT_STREQ(host.c_str(), "example.com"); +} + TEST(TestURL, IPAuthority) { std::string host;