Merge pull request #2171 from ianmacd/pr2
Don't nanny the user. Allow all file types as attachments.pull/2173/head
commit
f475fe8de8
@ -1,34 +0,0 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { isFileDangerous } from '../../util/isFileDangerous';
|
||||
|
||||
describe('isFileDangerous', () => {
|
||||
it('returns false for images', () => {
|
||||
assert.strictEqual(isFileDangerous('dog.gif'), false);
|
||||
assert.strictEqual(isFileDangerous('cat.jpg'), false);
|
||||
});
|
||||
|
||||
it('returns false for documents', () => {
|
||||
assert.strictEqual(isFileDangerous('resume.docx'), false);
|
||||
assert.strictEqual(isFileDangerous('price_list.pdf'), false);
|
||||
});
|
||||
|
||||
it('returns true for executable files', () => {
|
||||
assert.strictEqual(isFileDangerous('run.exe'), true);
|
||||
assert.strictEqual(isFileDangerous('install.pif'), true);
|
||||
});
|
||||
|
||||
it('returns false for empty filename', () => {
|
||||
assert.strictEqual(isFileDangerous(''), false);
|
||||
});
|
||||
|
||||
it('returns false for exe at various parts of filename', () => {
|
||||
assert.strictEqual(isFileDangerous('.exemanifesto.txt'), false);
|
||||
assert.strictEqual(isFileDangerous('runexe'), false);
|
||||
assert.strictEqual(isFileDangerous('run_exe'), false);
|
||||
});
|
||||
|
||||
it('returns true for upper-case EXE', () => {
|
||||
assert.strictEqual(isFileDangerous('run.EXE'), true);
|
||||
});
|
||||
});
|
@ -1,6 +0,0 @@
|
||||
// tslint:disable-next-line max-line-length
|
||||
const DANGEROUS_FILE_TYPES = /\.(ADE|ADP|APK|BAT|CHM|CMD|COM|CPL|DLL|DMG|EXE|HTA|INS|ISP|JAR|JS|JSE|LIB|LNK|MDE|MSC|MSI|MSP|MST|NSH|PIF|SCR|SCT|SHB|SYS|VB|VBE|VBS|VXD|WSC|WSF|WSH|CAB)$/i;
|
||||
|
||||
export function isFileDangerous(fileName: string): boolean {
|
||||
return DANGEROUS_FILE_TYPES.test(fileName);
|
||||
}
|
Loading…
Reference in New Issue