]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
src/rgw: Fix for malformed url
authorKalpesh Pandya <kapandya@redhat.com>
Wed, 13 Oct 2021 19:59:06 +0000 (01:29 +0530)
committerKalpesh Pandya <kapandya@redhat.com>
Mon, 18 Oct 2021 06:38:51 +0000 (12:08 +0530)
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 <kapandya@redhat.com>
src/rgw/rgw_url.cc
src/test/rgw/test_rgw_url.cc

index 58f7b5490538c36b26764047fdf606fe2a241c77..7fd4788d77c6d01500a3295d008fb1dc97914d60 100644 (file)
@@ -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) {
index d38457b815d2ea24ce7676d4e94dbf77389ad281..b61e1d5959210ec16dde06ec6b251e692114dc2a 100644 (file)
@@ -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;