]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Fix bucket name input allows space in the value 42241/head
authorNizamudeen A <nia@redhat.com>
Fri, 25 Jun 2021 13:30:42 +0000 (19:00 +0530)
committerNizamudeen A <nia@redhat.com>
Thu, 8 Jul 2021 07:30:46 +0000 (13:00 +0530)
Fixes: https://tracker.ceph.com/issues/51368
Signed-off-by: Nizamudeen A <nia@redhat.com>
(cherry picked from commit 2e94611a65c26f1db79d535f2a32e8bc747ecdd7)

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts

index ce9dce67a42b85dd16fefb4060c5d4a0186f3be1..c6902afb9742a28e29c7cf5266f3f48e27adb717 100644 (file)
@@ -134,6 +134,10 @@ describe('RgwBucketFormComponent', () => {
       testValidator('bucket-name-is-unique', true);
     }));
 
+    it('bucket names must not contain spaces', fakeAsync(() => {
+      testValidator('bucket name  with   spaces', false, 'onlyLowerCaseAndNumbers');
+    }));
+
     it('should get zonegroup and placement targets', () => {
       const payload: Record<string, any> = {
         zonegroup: 'default',
index 4d9d9aaec4b1cb82c23f6c103bdb4fadbfd89608..32a9fe0c2755cc41bbc1986977432d78d3fecff0 100644 (file)
@@ -269,7 +269,7 @@ export class RgwBucketFormComponent implements OnInit {
             return false;
           }
           // Bucket names can contain lowercase letters, numbers, and hyphens.
-          if (!/[0-9a-z-]/.test(label)) {
+          if (!/^\S*$/.test(name) || !/[0-9a-z-]/.test(label)) {
             errorName = 'onlyLowerCaseAndNumbers';
             return false;
           }