Skip to content

Commit 0ed241a

Browse files
committed
ACP2E-446:[Magento Quans] Any insight into why to the insight sanitation on the new media gallery is now more restrictive
1 parent 52c8dd3 commit 0ed241a

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGalleryCreateDeleteFolderTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<grabTextFrom selector="{{AdminMediaGalleryFolderSection.folderNameValidationMessage}}" stepKey="grabValidationMessage"/>
4646
<assertStringContainsString stepKey="assertFirst">
4747
<actualResult type="variable">grabValidationMessage</actualResult>
48-
<expectedResult type="string">Please use only letters (a-z or A-Z) or numbers (0-9) in this field. No spaces or other characters are allowed.</expectedResult>
48+
<expectedResult type="string">Please use only letters (a-z or A-Z), numbers (0-9), underscore (_) or hyphen (-) in this field. No spaces or other characters are allowed.</expectedResult>
4949
</assertStringContainsString>
5050

5151
<actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createNewFolder"/>

app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminStandaloneMediaGalleryCreateDeleteFolderTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<grabTextFrom selector="{{AdminMediaGalleryFolderSection.folderNameValidationMessage}}" stepKey="grabValidationMessage"/>
4848
<assertStringContainsString stepKey="assertFirst">
4949
<actualResult type="variable">grabValidationMessage</actualResult>
50-
<expectedResult type="string">Please use only letters (a-z or A-Z) or numbers (0-9) in this field. No spaces or other characters are allowed.</expectedResult>
50+
<expectedResult type="string">Please use only letters (a-z or A-Z), numbers (0-9), underscore (_) or hyphen (-) in this field. No spaces or other characters are allowed.</expectedResult>
5151
</assertStringContainsString>
5252

5353
<actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createNewFolder"/>

app/code/Magento/MediaGalleryUi/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Directory,Directory
66
"Modification Date","Modification Date"
77
Overlay,Overlay
88
"Thumbnail Image","Thumbnail Image"
9+
"Please use only letters (a-z or A-Z), numbers (0-9), underscore (_) or hyphen (-) in this field. No spaces or other characters are allowed.","Please use only letters (a-z or A-Z), numbers (0-9), underscore (_) or hyphen (-) in this field. No spaces or other characters are allowed."

app/code/Magento/MediaGalleryUi/view/adminhtml/templates/container.phtml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
"masonryComponentPath": "media_gallery_listing.media_gallery_listing.media_gallery_columns"
2424
}
2525
}
26-
},
27-
"Magento_MediaGalleryUi/js/validation/validate-filename": {}
26+
}
2827
}
2928
}
3029
</script>

app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/directory/directories.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ define([
3939
*/
4040
initialize: function () {
4141
this._super().observe(['selectedFolder']);
42+
this._addValidation();
4243
this.initEvents();
4344

4445
return this;
@@ -191,6 +192,17 @@ define([
191192

192193
this.selectedFolder(folderId);
193194
$(this.deleteButtonSelector).prop('disabled', false).removeClass('disabled');
195+
},
196+
197+
/**
198+
* @private
199+
*/
200+
_addValidation: function () {
201+
$.validator.addMethod(
202+
'validate-filename', function (value) {
203+
return $.mage.isEmptyNoTrim(value) || /^[a-z0-9\-\_]+$/si.test(value);
204+
},
205+
$.mage.__('Please use only letters (a-z or A-Z), numbers (0-9), underscore (_) or hyphen (-) in this field. No spaces or other characters are allowed.')); //eslint-disable-line max-len
194206
}
195207
});
196208
});

0 commit comments

Comments
 (0)