Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove filetype restriction for file uploads #21285

Merged
merged 4 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 0 additions & 58 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
11 changes: 0 additions & 11 deletions src/components/AttachmentModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
youssef-lr marked this conversation as resolved.
Show resolved Hide resolved
import themeColors from '../styles/themes/default';
import compose from '../libs/compose';
import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions';
Expand Down Expand Up @@ -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'));
Expand Down
2 changes: 0 additions & 2 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
youssef-lr marked this conversation as resolved.
Show resolved Hide resolved
},
avatarCropModal: {
title: 'Edit photo',
Expand Down
2 changes: 0 additions & 2 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading