]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Fix bucket name input allows space in the value
authorNizamudeen A <nia@redhat.com>
Fri, 25 Jun 2021 13:30:42 +0000 (19:00 +0530)
committerNizamudeen A <nia@redhat.com>
Wed, 30 Jun 2021 06:20:52 +0000 (11:50 +0530)
Fixes: https://tracker.ceph.com/issues/51368
Signed-off-by: Nizamudeen A <nia@redhat.com>
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 72a37309c4eb7684dd97c2ef959c2742a8ac5c22..a2d8854adc873feea0cfdf03d753b3d84dff6381 100644 (file)
@@ -136,6 +136,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 07160445206d31f39ac71ce106b8706b51470113..80ff2c8538a5a24ed8ab1295f80a4e9ce05bfb41 100644 (file)
@@ -282,7 +282,7 @@ export class RgwBucketFormComponent extends CdForm 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;
           }