]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: handle trailing slashes in Static Website in way compliant with Swift.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Thu, 15 Sep 2016 18:02:28 +0000 (20:02 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Thu, 15 Sep 2016 18:18:07 +0000 (20:18 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_rest_swift.cc

index 9441900841e1a68d6850e0ce74e5e905c6c8c26b..b52019915f078add443cb016a9ce2431f5dadb93 100644 (file)
@@ -1749,7 +1749,12 @@ RGWOp* RGWSwiftWebsiteHandler::get_ws_listing_op()
                              ws_conf.listing_css_doc);
 
       for (const auto& pair : common_prefixes) {
-        const std::string& subdir_name = pair.first;
+        std::string subdir_name = pair.first;
+        if (! subdir_name.empty()) {
+          /* To be compliant with Swift we need to remove the trailing
+           * slash. */
+          subdir_name.pop_back();
+        }
 
         htmler.dump_subdir(subdir_name);
       }
@@ -1779,7 +1784,8 @@ RGWOp* RGWSwiftWebsiteHandler::get_ws_listing_op()
 
 bool RGWSwiftWebsiteHandler::is_web_dir() const
 {
-  std::string subdir_name = s->object.name;
+  std::string subdir_name;
+  url_decode(s->object.name, subdir_name);
 
   /* Remove character from the subdir name if it is "/". */
   if (subdir_name.empty()) {
@@ -1844,7 +1850,7 @@ int RGWSwiftWebsiteHandler::retarget_bucket(RGWOp* op, RGWOp** new_op)
     const auto& ws_conf = s->bucket_info.website_conf;
     const auto& index = s->bucket_info.website_conf.get_index_doc();
 
-    if (s->info.request_uri.back() != '/') {
+    if (s->decoded_uri.back() != '/') {
       op_override = get_ws_redirect_op();
     } else if (! index.empty() && is_index_present(index)) {
       op_override = get_ws_index_op();
@@ -1878,7 +1884,7 @@ int RGWSwiftWebsiteHandler::retarget_object(RGWOp* op, RGWOp** new_op)
     const auto& ws_conf = s->bucket_info.website_conf;
     const auto& index = s->bucket_info.website_conf.get_index_doc();
 
-    if (s->info.request_uri.back() != '/') {
+    if (s->decoded_uri.back() != '/') {
       op_override = get_ws_redirect_op();
     } else if (! index.empty() && is_index_present(index)) {
       op_override = get_ws_index_op();