From: Nizamudeen A Date: Tue, 26 Mar 2024 07:53:39 +0000 (+0530) Subject: mgr/dashboard: fix cephfs name validation X-Git-Tag: v20.0.0~2285^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=242318452c8111717e49b896c7f9cf0ec5f5b262;p=ceph.git mgr/dashboard: fix cephfs name validation allow volume name to start with dot (.) Fixes: https://tracker.ceph.com/issues/65143 Signed-off-by: Nizamudeen A --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html index f8d0fa8032040..958a4bff2a2d6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html @@ -47,7 +47,7 @@ i18n>This field is required! File System name should start with a letter and can only contain letters, numbers, '.', '-' or '_' + i18n>File System name should start with a letter or dot (.) and can only contain letters, numbers, '.', '-' or '_' diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts index 520f726d5553c..3bcedd1cd6693 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts @@ -42,7 +42,15 @@ describe('CephfsVolumeFormComponent', () => { }); it('should validate proper names', fakeAsync(() => { - const validNames = ['test', 'test1234', 'test_1234', 'test-1234', 'test.1234', 'test12test']; + const validNames = [ + 'test', + 'test1234', + 'test_1234', + 'test-1234', + 'test.1234', + 'test12test', + '.test' + ]; const invalidNames = ['1234', 'test@', 'test)']; for (const validName of validNames) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts index b0f90979c252b..dbbe522fa0a19 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts @@ -87,7 +87,10 @@ export class CephfsVolumeFormComponent extends CdForm implements OnInit { }); this.form = this.formBuilder.group({ name: new FormControl('', { - validators: [Validators.pattern(/^[a-zA-Z][.A-Za-z0-9_-]+$/), Validators.required] + validators: [ + Validators.pattern(/^(?:[.][A-Za-z0-9_-]+|[A-Za-z][.A-Za-z0-9_-]*)$/), + Validators.required + ] }), placement: ['hosts'], hosts: [[]],