Skip to content

fix(matrix): preserve table HTML in sanitizer#44848

Open
nepenth wants to merge 1 commit into
NousResearch:mainfrom
nepenth:codex/matrix-html-table-sanitizer
Open

fix(matrix): preserve table HTML in sanitizer#44848
nepenth wants to merge 1 commit into
NousResearch:mainfrom
nepenth:codex/matrix-html-table-sanitizer

Conversation

@nepenth

@nepenth nepenth commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a Matrix rendering regression introduced by #18505: the new Matrix HTML sanitizer stripped table structure emitted by the existing Markdown tables extension.

Changes

  • Add Matrix-compatible table structure tags to _MatrixHtmlSanitizer:
    • table
    • thead
    • tbody
    • tfoot
    • tr
    • th
    • td
  • Preserve the existing sanitizer posture by continuing to strip unsafe attributes such as event handlers and inline styles.
  • Add regression coverage for sanitized table HTML and optional Markdown-table output when the markdown package is installed.

Validation

.venv/bin/python -m pytest tests/gateway/test_matrix.py::TestMatrixMarkdownToHtml -q
.venv/bin/python -m pytest tests/gateway/test_matrix.py -q
.venv/bin/python -m py_compile gateway/platforms/matrix.py
git diff --check

Results:

  • 13 passed, 1 skipped
  • 230 passed, 1 skipped
  • py_compile passed
  • git diff --check passed

@tonydwb tonydwb 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.

Good fix. Adds table HTML tags (table, tbody, td, tfoot, th, thead, tr) to Matrix sanitizer allowlist. Tests confirm onclick and style attributes are stripped while table content is preserved. No issues found.

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