From 9ee915d70afb644f6790756471566819fbf70e2c Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Thu, 22 Jun 2023 00:45:55 +0100 Subject: [PATCH 1/3] Remove filetype restriction for file uploads --- src/CONST.js | 58 ------------------------------- src/components/AttachmentModal.js | 11 ------ 2 files changed, 69 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 85ee667eead5..75b9f1a61e9b 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -35,64 +35,6 @@ const CONST = { ARROW_HIDE_DELAY: 3000, API_ATTACHMENT_VALIDATIONS: { - // Same as the PHP layer allows - /* eslint-disable-next-line max-len */ - UNALLOWED_EXTENSIONS: [ - 'ade', - 'adp', - 'apk', - 'appx', - 'appxbundle', - 'bat', - 'cab', - 'chm', - 'cmd', - 'com', - 'cpl', - 'diagcab', - 'diagcfg', - 'diagpack', - 'dll', - 'dmg', - 'ex', - 'ex_', - 'exe', - 'hta', - 'img', - 'ins', - 'iso', - 'isp', - 'jar', - 'jnlp', - 'js', - 'jse', - 'lib', - 'lnk', - 'mde', - 'msc', - 'msi', - 'msix', - 'msixbundle', - 'msp', - 'mst', - 'nsh', - 'pif', - 'ps1', - 'scr', - 'sct', - 'shb', - 'sys', - 'vb', - 'vbe', - 'vbs', - 'vhd', - 'vxd', - 'wsc', - 'wsf', - 'wsh', - 'xll', - ], - // 24 megabytes in bytes, this is limit set on servers, do not update without wider internal discussion MAX_SIZE: 25165824, diff --git a/src/components/AttachmentModal.js b/src/components/AttachmentModal.js index a481a4026659..c1843a931815 100755 --- a/src/components/AttachmentModal.js +++ b/src/components/AttachmentModal.js @@ -11,7 +11,6 @@ import AttachmentView from './AttachmentView'; import AttachmentCarousel from './AttachmentCarousel'; import styles from '../styles/styles'; import * as StyleUtils from '../styles/StyleUtils'; -import * as FileUtils from '../libs/fileDownload/FileUtils'; import themeColors from '../styles/themes/default'; import compose from '../libs/compose'; import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions'; @@ -166,16 +165,6 @@ function AttachmentModal(props) { */ const isValidFile = useCallback( (_file) => { - const {fileExtension} = FileUtils.splitExtensionFromFileName(lodashGet(_file, 'name', '')); - if (_.contains(CONST.API_ATTACHMENT_VALIDATIONS.UNALLOWED_EXTENSIONS, fileExtension.toLowerCase())) { - const invalidReason = props.translate('attachmentPicker.notAllowedExtension'); - - setIsAttachmentInvalid(true); - setAttachmentInvalidReasonTitle(props.translate('attachmentPicker.wrongFileType')); - setAttachmentInvalidReason(invalidReason); - return false; - } - if (lodashGet(_file, 'size', 0) > CONST.API_ATTACHMENT_VALIDATIONS.MAX_SIZE) { setIsAttachmentInvalid(true); setAttachmentInvalidReasonTitle(props.translate('attachmentPicker.attachmentTooLarge')); From 0b0de987910cd894784871fd37876fa27fe89615 Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Fri, 7 Jul 2023 13:19:57 +0100 Subject: [PATCH 2/3] Remove translation keys no longer used --- src/languages/en.js | 2 -- src/languages/es.js | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index 192d9954e5ff..5ed8bc64a56d 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -163,8 +163,6 @@ export default { sizeExceeded: 'Attachment size is larger than 24 MB limit.', attachmentTooSmall: 'Attachment too small', sizeNotMet: 'Attachment size must be greater than 240 bytes.', - wrongFileType: 'Attachment is the wrong type', - notAllowedExtension: 'This filetype is not allowed', }, avatarCropModal: { title: 'Edit photo', diff --git a/src/languages/es.js b/src/languages/es.js index d54fa5110117..e55c794fe989 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -162,8 +162,6 @@ export default { sizeExceeded: 'El archivo adjunto supera el límite de 24 MB.', attachmentTooSmall: 'Archivo adjunto demasiado pequeño', sizeNotMet: 'El archivo adjunto debe ser mas grande que 240 bytes.', - wrongFileType: 'El tipo del archivo adjunto es incorrecto', - notAllowedExtension: 'Este tipo de archivo no está permitido', }, avatarCropModal: { title: 'Editar foto', From 4118f4b7891269892d1e14f6279805968c3852ac Mon Sep 17 00:00:00 2001 From: Youssef Lourayad Date: Tue, 8 Aug 2023 21:31:03 +0100 Subject: [PATCH 3/3] Add back code removed by mistake --- src/components/AttachmentModal.js | 1 + src/languages/en.js | 1 + src/languages/es.js | 1 + 3 files changed, 3 insertions(+) diff --git a/src/components/AttachmentModal.js b/src/components/AttachmentModal.js index 8f827dfefb62..dbfdefe7a0f2 100755 --- a/src/components/AttachmentModal.js +++ b/src/components/AttachmentModal.js @@ -12,6 +12,7 @@ import AttachmentView from './AttachmentView'; import AttachmentCarousel from './AttachmentCarousel'; import styles from '../styles/styles'; import * as StyleUtils from '../styles/StyleUtils'; +import * as FileUtils from '../libs/fileDownload/FileUtils'; import themeColors from '../styles/themes/default'; import compose from '../libs/compose'; import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions'; diff --git a/src/languages/en.js b/src/languages/en.js index f9bad6fb4402..54a1d1acbede 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -169,6 +169,7 @@ export default { attachmentTooSmall: 'Attachment too small', sizeNotMet: 'Attachment size must be greater than 240 bytes.', wrongFileType: 'Attachment is the wrong type', + notAllowedExtension: 'This filetype is not allowed', folderNotAllowedMessage: 'Uploading a folder is not allowed. Try a different file.', }, avatarCropModal: { diff --git a/src/languages/es.js b/src/languages/es.js index ed5a472ad1a3..58146873da87 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -168,6 +168,7 @@ export default { attachmentTooSmall: 'Archivo adjunto demasiado pequeño', sizeNotMet: 'El archivo adjunto debe ser mas grande que 240 bytes.', wrongFileType: 'El tipo del archivo adjunto es incorrecto', + notAllowedExtension: 'Este tipo de archivo no está permitido', folderNotAllowedMessage: 'Subir una carpeta no está permitido. Prueba con otro archivo.', }, avatarCropModal: {