Skip to content

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

Merged
dklawren merged 5 commits into
mozilla:masterfrom
suhaibmujahid:worktree-bug-2060932-details
Sep 16, 2026
Merged

dklawren merged 5 commits 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 Outdated
@dklawren

Copy link
Copy Markdown
Collaborator

@kyoshino Is this something that you could take over and finish for us? Given your past experience with markdown comments and rendering.

@kyoshino

Copy link
Copy Markdown
Collaborator

Sure, will check it out!

@dklawren
dklawren requested a balanced review from Copilot September 16, 2026 14:56
@dklawren dklawren self-assigned this Sep 16, 2026
@dklawren
dklawren marked this pull request as ready for review September 16, 2026 14:57

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.

🟡 Changes recommended

Entity-encoded marker characters can forge disclosure tags, and code literals lose their original casing.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread Bugzilla/Markdown.pm
Comment thread Bugzilla/Markdown.pm Outdated
@kyoshino

Copy link
Copy Markdown
Collaborator

Tested quickly, locally. If the open attribute is attached, it doesn’t work. Nested <details> are fine.

https://gist.github.com/scmx/eca72d44afee0113ceb0349dd54a84a2

image

@kyoshino

Copy link
Copy Markdown
Collaborator

Also a header in title needs display: inline-block:

<details><summary>

# Summary (h1)
</summary>
content
</details>
image

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.

🟡 Changes recommended

Unicode case folding can cause unsupported tag spellings to be silently deleted.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread Bugzilla/Markdown.pm

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.

🟡 Changes recommended

Backslash-escaped disclosure tags are incorrectly activated, and the documented attribute policy conflicts with the implementation.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

Bugzilla/Markdown.pm:152

  • This substitution also marks backslash-escaped tags. In GFM, \<details> is literal text, but replacing <details> before cmark sees it prevents the backslash escape from being applied; the second pass then creates an active disclosure element (and leaves the backslash visible). Please skip tags preceded by an odd-length run of backslashes and add a regression test for escaped opening and closing tags.
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread Bugzilla/Markdown.pm
@dklawren
dklawren merged commit 3bf44e7 into mozilla:master Sep 16, 2026
8 checks passed
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.

4 participants