[% END %]
[% BLOCK comment_header %]
- <div class="comment" data-id="[% comment.id FILTER none %]" data-no="[% comment.count FILTER none %]">
+ <div class="comment" data-id="[% comment.id FILTER none %]" data-no="[% comment.count FILTER none %]"
+ data-tags="[% comment.tags.join(' ') FILTER html %]">
[%# normal comment header %]
<table class="layout-table change-head [% extra_class FILTER none %]" id="ch-[% comment.count FILTER none %]"
[% IF comment.collapsed +%] style="display:none"[% END %]>
BUGZILLA.bug_title = '[% unfiltered_title FILTER js %]';
BUGZILLA.bug_summary = '[% bug.short_desc FILTER js %]';
BUGZILLA.bug_url = '[% Bugzilla.localconfig.canonical_urlbase _ "show_bug.cgi?id=" _ bug.id FILTER js %]';
+ BUGZILLA.bug_keywords = '[% bug.keywords FILTER js %]',
BUGZILLA.user = {
id: [% user.id FILTER none %],
login: '[% user.login FILTER js %]',
root.append(span);
});
$('#ctag-' + commentNo + ' .comment-tags').append($('#ctag-error'));
+ $(`.comment[data-no="${commentNo}"]`).attr('data-tags', tags.join(' '));
}
var refreshXHR;
* @see https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API
*/
prepare_inline_attachments() {
- // Check the user setting, API support and connectivity
- if (!BUGZILLA.user.settings.inline_attachments || typeof IntersectionObserver !== 'function' ||
- (navigator.connection && navigator.connection.type === 'cellular')) {
+ // Check the connectivity, API support, user setting and sensitive keywords
+ if ((navigator.connection && navigator.connection.type === 'cellular') ||
+ typeof IntersectionObserver !== 'function' || !BUGZILLA.user.settings.inline_attachments ||
+ BUGZILLA.bug_keywords.split(', ').find(keyword => keyword.match(/^(hang|assertion|crash)$/))) {
return;
}
}
}), { root: document.querySelector('#bugzilla-body') });
- // Show attachments except for obsolete or deleted ones
- document.querySelectorAll('.change-set .attachment:not(.obsolete):not(.deleted)')
- .forEach($att => observer.observe($att));
+ document.querySelectorAll('.change-set').forEach($set => {
+ // Skip if the comment has the `hide-attachment` tag
+ 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) {
+ observer.observe($attachment);
+ }
+ });
}
/**