From: Nizamudeen A Date: Fri, 25 Jun 2021 13:30:42 +0000 (+0530) Subject: mgr/dashboard: Fix bucket name input allows space in the value X-Git-Tag: v15.2.14~28^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F42241%2Fhead;p=ceph.git mgr/dashboard: Fix bucket name input allows space in the value Fixes: https://tracker.ceph.com/issues/51368 Signed-off-by: Nizamudeen A (cherry picked from commit 2e94611a65c26f1db79d535f2a32e8bc747ecdd7) --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts index ce9dce67a42b..c6902afb9742 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts @@ -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 = { zonegroup: 'default', diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts index 4d9d9aaec4b1..32a9fe0c2755 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts @@ -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; }