diff --git a/js/test/AttachmentViewer.js b/js/test/AttachmentViewer.js
index 2a03ef54..99ff298e 100644
--- a/js/test/AttachmentViewer.js
+++ b/js/test/AttachmentViewer.js
@@ -129,5 +129,46 @@ describe('AttachmentViewer', function () {
return results.every(element => element);
}
);
+
+ it(
+ 'sanitizes file names in attachments',
+ function() {
+ const clean = jsdom();
+ $('body').html(
+ '
' +
+ '' +
+ ''
+ );
+ // mock createObjectURL for jsDOM
+ if (typeof window.URL.createObjectURL === 'undefined') {
+ Object.defineProperty(
+ window.URL,
+ 'createObjectURL',
+ {value: function(blob) {
+ return 'blob:' + location.origin + '/1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed';
+ }}
+ )
+ }
+ $.PrivateBin.AttachmentViewer.init();
+ $.PrivateBin.Model.init();
+ global.atob = common.atob;
+
+ const maliciousFileNames = [
+ '