diff --git a/src/bundle/Resources/public/js/scripts/fieldType/ezbinaryfile.js b/src/bundle/Resources/public/js/scripts/fieldType/ezbinaryfile.js index 29317449cc..fe96831ddc 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/ezbinaryfile.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/ezbinaryfile.js @@ -1,4 +1,4 @@ -(function(global, doc, eZ) { +(function (global, doc, eZ) { const SELECTOR_FIELD = '.ez-field-edit--ezbinaryfile'; const SELECTOR_LABEL_WRAPPER = '.ez-field-edit__label-wrapper'; const SELECTOR_FILESIZE_NOTICE = '.ez-data-source__message--filesize'; @@ -15,9 +15,11 @@ const sizeContainer = preview.querySelector('.ez-field-edit-preview__file-size'); const files = [].slice.call(event.target.files); const fileSize = this.formatFileSize(files[0].size); + const { escapeHTML } = eZ.helpers.text; + const fileName = escapeHTML(files[0].name); - nameContainer.innerHTML = files[0].name; - nameContainer.title = files[0].name; + nameContainer.innerHTML = fileName; + nameContainer.title = fileName; sizeContainer.innerHTML = fileSize; sizeContainer.title = fileSize; @@ -63,5 +65,5 @@ previewField.init(); eZ.addConfig('fieldTypeValidators', [validator], true); - }) + }); })(window, window.document, window.eZ); diff --git a/src/bundle/Resources/public/js/scripts/fieldType/ezimage.js b/src/bundle/Resources/public/js/scripts/fieldType/ezimage.js index b608dc855c..884565be40 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/ezimage.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/ezimage.js @@ -1,4 +1,4 @@ -(function(global, doc, eZ) { +(function (global, doc, eZ) { const SELECTOR_FIELD = '.ez-field-edit--ezimage'; const SELECTOR_INPUT_FILE = 'input[type="file"]'; const SELECTOR_LABEL_WRAPPER = '.ez-field-edit__label-wrapper'; @@ -36,11 +36,13 @@ const sizeContainer = preview.querySelector('.ez-field-edit-preview__file-size'); const files = [].slice.call(event.target.files); const fileSize = this.formatFileSize(files[0].size); + const { escapeHTML } = eZ.helpers.text; + const fileName = escapeHTML(files[0].name); this.getImageUrl(files[0], (url) => image.setAttribute('src', url)); - nameContainer.innerHTML = files[0].name; - nameContainer.title = files[0].name; + nameContainer.innerHTML = fileName; + nameContainer.title = fileName; sizeContainer.innerHTML = fileSize; sizeContainer.title = fileSize; diff --git a/src/bundle/Resources/public/js/scripts/fieldType/ezmedia.js b/src/bundle/Resources/public/js/scripts/fieldType/ezmedia.js index 99745ec6cc..6016dccf4b 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/ezmedia.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/ezmedia.js @@ -1,4 +1,4 @@ -(function(global, doc, eZ) { +(function (global, doc, eZ) { const SELECTOR_FIELD = '.ez-field-edit--ezmedia'; const SELECTOR_PREVIEW = '.ez-field-edit__preview'; const SELECTOR_MEDIA = '.ez-field-edit-preview__media'; @@ -62,9 +62,11 @@ const sizeContainer = preview.querySelector('.ez-field-edit-preview__file-size'); const files = [].slice.call(event.target.files); const fileSize = this.formatFileSize(files[0].size); + const { escapeHTML } = eZ.helpers.text; + const fileName = escapeHTML(files[0].name); - nameContainer.innerHTML = files[0].name; - nameContainer.title = files[0].name; + nameContainer.innerHTML = fileName; + nameContainer.title = fileName; sizeContainer.innerHTML = fileSize; sizeContainer.title = fileSize;