- {extension}
+
+
+ {extension ? (
+
+ {extension}
+
+ ) : null}
+
+ {isDangerous ? (
+
) : null}
@@ -734,9 +743,16 @@ export class Message extends React.Component
{
return null;
}
+ const fileName = attachment && attachment.fileName;
+ const isDangerous = isFileDangerous(fileName || '');
+
const downloadButton = attachment ? (
{
+ if (onDownload) {
+ onDownload(isDangerous);
+ }
+ }}
role="button"
className={classNames(
'module-message__buttons__download',
diff --git a/ts/util/index.ts b/ts/util/index.ts
index d5af9febc13..b667028a38e 100644
--- a/ts/util/index.ts
+++ b/ts/util/index.ts
@@ -1,6 +1,13 @@
import * as GoogleChrome from './GoogleChrome';
import { arrayBufferToObjectURL } from './arrayBufferToObjectURL';
+import { isFileDangerous } from './isFileDangerous';
import { missingCaseError } from './missingCaseError';
import { migrateColor } from './migrateColor';
-export { arrayBufferToObjectURL, GoogleChrome, missingCaseError, migrateColor };
+export {
+ arrayBufferToObjectURL,
+ GoogleChrome,
+ isFileDangerous,
+ migrateColor,
+ missingCaseError,
+};
diff --git a/ts/util/isFileDangerous.ts b/ts/util/isFileDangerous.ts
new file mode 100644
index 00000000000..2d39baa1cd7
--- /dev/null
+++ b/ts/util/isFileDangerous.ts
@@ -0,0 +1,6 @@
+// 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);
+}