From c30a1ea66e47ec79c7e87caf3f71e5c7cf85b2b1 Mon Sep 17 00:00:00 2001 From: Luis Daniel Castellanos Date: Fri, 23 Sep 2016 16:25:59 -0500 Subject: [PATCH] Fix for swift ui displaying infinite folders When creating a folder in swift ui with the following name format "f1;/f2" swift ui is not able to pick the objects/floders for "f1;" and when this folder is selected the ui ends in an infinite loop of "f1;" folders Change-Id: I8e2d8fdb5fb3b67dfd14bbdd1b100f13e84222eb Closes-Bug: #1624546 --- openstack_dashboard/api/rest/swift.py | 3 +++ .../dashboard/project/containers/containers-model.service.js | 4 ++-- .../project/containers/containers-model.service.spec.js | 2 +- .../dashboard/project/containers/create-folder-modal.html | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/openstack_dashboard/api/rest/swift.py b/openstack_dashboard/api/rest/swift.py index 1dd4ee1580..5deeffa585 100644 --- a/openstack_dashboard/api/rest/swift.py +++ b/openstack_dashboard/api/rest/swift.py @@ -17,6 +17,7 @@ import os from django import forms from django.http import StreamingHttpResponse +from django.utils.http import urlunquote from django.views.decorators.csrf import csrf_exempt from django.views import generic import six @@ -120,6 +121,8 @@ class Objects(generic.View): :return: """ path = request.GET.get('path') + if path is not None: + path = urlunquote(path) objects = api.swift.swift_get_objects( request, diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.js b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.js index 420482f5bc..e9fb9864ba 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.js @@ -121,7 +121,7 @@ delimiter: model.DELIMETER }; if (folder) { - spec.path = folder + model.DELIMETER; + spec.path = encodeURIComponent(folder) + model.DELIMETER; } return swiftAPI.getObjects(name, spec).then(function onObjects(response) { @@ -279,7 +279,7 @@ state.counted.folders++; var spec = { delimiter: model.DELIMETER, - path: item.path + model.DELIMETER + path: encodeURIComponent(item.path).replace(/%2F/g, '/') }; return swiftAPI.getObjects(model.container.name, spec) .then(function objects(response) { diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.spec.js b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.spec.js index 4fcfc96770..e3e5e565ad 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.spec.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers-model.service.spec.js @@ -244,7 +244,7 @@ beforeEach(function before() { spyOn(swiftAPI, 'getObjects').and.callFake(function fake(container, spec) { var deferred = $q.defer(); - var items = fakeSwift[spec.path]; + var items = fakeSwift[spec.path + '/']; expect(items).toBeDefined(); // sanity check deferred.resolve({data: {items: items}}); return deferred.promise; diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/create-folder-modal.html b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/create-folder-modal.html index c2c83b8274..4667415dde 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/create-folder-modal.html +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/create-folder-modal.html @@ -8,7 +8,7 @@ -