From 79eadd23080635f7f5bd84d61f8dd4bbaecb30e0 Mon Sep 17 00:00:00 2001 From: Kohei Yoshino Date: Mon, 6 May 2019 13:53:29 -0400 Subject: [PATCH] =?utf8?q?Bug=201547714=20-=20Attachment=20with=20applicat?= =?utf8?q?ion/octet-stream=20MIME=20type=20should=20not=20be=20previewed?= =?utf8?q?=20even=20if=20it=E2=80=99s=20actually=20text=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- extensions/BugModal/web/comments.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/extensions/BugModal/web/comments.js b/extensions/BugModal/web/comments.js index 39607fbf1..24767c0bc 100644 --- a/extensions/BugModal/web/comments.js +++ b/extensions/BugModal/web/comments.js @@ -545,10 +545,8 @@ Bugzilla.BugModal.Comments = class Comments { const $comment = $set.querySelector('.comment:not([data-tags~="hide-attachment"])'); // Skip if the attachment is obsolete or deleted const $attachment = $set.querySelector('.attachment:not(.obsolete):not(.deleted)'); - // Skip if the attachment is SVG image - const is_svg = !!$set.querySelector('.attachment [itemprop="encodingFormat"][content="image/svg+xml"]'); - if ($comment && $attachment && !is_svg) { + if ($comment && $attachment) { observer.observe($attachment); } }); @@ -566,8 +564,13 @@ Bugzilla.BugModal.Comments = class Comments { const size = Number($att.querySelector('[itemprop="contentSize"]').content); const max_size = 2000000; - // Show image smaller than 2 MB - if (type.match(/^image\/(?!vnd).+$/) && size < max_size) { + // Skip if the attachment is marked as binary + if (type.match(/^application\/(?:octet-stream|binary)$/)) { + return; + } + + // Show image smaller than 2 MB, excluding SVG and non-standard formats + if (type.match(/^image\/(?!vnd|svg).+$/) && size < max_size) { $att.insertAdjacentHTML('beforeend', ` ${name.htmlEncode()}`); -- 2.47.3