]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1546877 - Slow Script warning on bugzilla page when loading preview of large...
authorKohei Yoshino <kohei.yoshino@gmail.com>
Thu, 9 May 2019 22:19:35 +0000 (18:19 -0400)
committerGitHub <noreply@github.com>
Thu, 9 May 2019 22:19:35 +0000 (18:19 -0400)
extensions/BugModal/web/comments.js

index 24767c0bc7e62f0f87d06c05f45afb43dd73ce37..5378b3dadb72009ffd78c08d2b234d06671dc22b 100644 (file)
@@ -562,7 +562,6 @@ Bugzilla.BugModal.Comments = class Comments {
     const name = $att.querySelector('[itemprop="name"]').content;
     const type = $att.querySelector('[itemprop="encodingFormat"]').content;
     const size = Number($att.querySelector('[itemprop="contentSize"]').content);
-    const max_size = 2000000;
 
     // Skip if the attachment is marked as binary
     if (type.match(/^application\/(?:octet-stream|binary)$/)) {
@@ -570,7 +569,7 @@ Bugzilla.BugModal.Comments = class Comments {
     }
 
     // Show image smaller than 2 MB, excluding SVG and non-standard formats
-    if (type.match(/^image\/(?!vnd|svg).+$/) && size < max_size) {
+    if (type.match(/^image\/(?!vnd|svg).+$/) && size < 2000000) {
       $att.insertAdjacentHTML('beforeend', `
         <a href="${link}" class="outer lightbox"><img src="${link}" alt="${name.htmlEncode()}" itemprop="image"></a>`);
 
@@ -601,8 +600,8 @@ Bugzilla.BugModal.Comments = class Comments {
     const is_source = !!name.match(/\.(?:cpp|es|h|js|json|rs|rst|sh|toml|ts|tsx|xml|yaml|yml)$/);
     const is_text = type.match(/^text\/(?!x-).+$/) || is_patch || is_markdown || is_source;
 
-    // Show text smaller than 2 MB
-    if (is_text && size < max_size) {
+    // Show text smaller than 50 KB
+    if (is_text && size < 50000) {
       // Load text body
       bugzilla_ajax({ url: `${BUGZILLA.config.basepath}rest/bug/attachment/${id}?include_fields=data` }, data => {
         if (data.error) {