]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1547714 - Attachment with application/octet-stream MIME type should not be previe...
authorKohei Yoshino <kohei.yoshino@gmail.com>
Mon, 6 May 2019 17:53:29 +0000 (13:53 -0400)
committerGitHub <noreply@github.com>
Mon, 6 May 2019 17:53:29 +0000 (13:53 -0400)
extensions/BugModal/web/comments.js

index 39607fbf10d5658e81b451cc52a19ab1e08fc484..24767c0bc7e62f0f87d06c05f45afb43dd73ce37 100644 (file)
@@ -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', `
         <a href="${link}" class="outer lightbox"><img src="${link}" alt="${name.htmlEncode()}" itemprop="image"></a>`);