Skip to content

Bug 2060932 - Support GitHub-style collapsible sections in comments - #2726

Draft
suhaibmujahid wants to merge 1 commit into
mozilla:masterfrom
suhaibmujahid:worktree-bug-2060932-details
Draft

Bug 2060932 - Support GitHub-style collapsible sections in comments#2726
suhaibmujahid wants to merge 1 commit into
mozilla:masterfrom
suhaibmujahid:worktree-bug-2060932-details

Conversation

@suhaibmujahid

Copy link
Copy Markdown
Member

Comments render markdown with cmark's safe option and every < escaped beforehand, so raw HTML never reaches the parser. Instead of weakening that, convert the four disclosure tags back to real elements after rendering: mark the escaped tags in text nodes (skipping pre/code so the syntax can still be documented), then re-parse so the block level elements are lifted out of the paragraph markdown wrapped them in.

Only those four exact tags are recognized and they never carry attributes, so no other markup can be smuggled in. The marker characters are stripped from the input so they cannot be forged, and unbalanced tags cannot leak an unclosed element into the page.

Comments render markdown with cmark's safe option and every `<` escaped
beforehand, so raw HTML never reaches the parser. Instead of weakening
that, convert the four disclosure tags back to real elements after
rendering: mark the escaped tags in text nodes (skipping pre/code so the
syntax can still be documented), then re-parse so the block level
elements are lifted out of the paragraph markdown wrapped them in.

Only those four exact tags are recognized and they never carry
attributes, so no other markup can be smuggled in. The marker characters
are stripped from the input so they cannot be forged, and unbalanced tags
cannot leak an unclosed element into the page.
Copilot AI balanced review requested due to automatic review settings August 25, 2026 16:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds GitHub-style collapsible comment sections while retaining safe Markdown rendering.

Changes:

  • Post-processes bare <details> and <summary> tags.
  • Adds disclosure rendering and security tests.
  • Styles disclosure elements in Markdown comments.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Bugzilla/Markdown.pm Expands disclosure tags after Markdown rendering.
t/markdown.t Tests disclosure rendering and safeguards.
skins/standard/global.css Styles collapsible sections.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Bugzilla/Markdown.pm
return unless $node->type eq 'text';
return if $node->ancestors('pre, code')->size;
my $text = $node->content;
return unless $text =~ s/($DISCLOSURE_RE)/$DISCLOSURE_MARKER{lc $1}/g;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants