Repository navigation
Backport #32313 to 2.0: preserve math equations through frontend and backend sanitizers - #32509
Conversation
…nitizers Math equations (block-math-equation nodes) were silently stripped on save because both the frontend DOMPurify sanitizer and the backend OWASP HTML sanitizer removed the unknown custom tag. Apply the same placeholder-protect pattern already used for entity links in both sanitizers, add block-math-equation to the OWASP allowlist, and fix the white-text-on-selection CSS bug. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…equations - Add per-call nonce to placeholder names so literal __OM_MATH_EQ_*__ text in descriptions cannot collide with generated placeholders (P1) - Use replacer function () => eq so $ sequences in LaTeX are inserted verbatim rather than interpreted as replacement patterns (bug fix) - Apply same function-replacer fix to entity link restoration - Remove // Restore math equations comment that restated the code (P2) - Apply same nonce to entity link placeholders for consistency Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
Code Review ✅ ApprovedBackport of math equation preservation fix to the 2.0 branch. Frontend and backend sanitizers now protect OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
✅ Playwright Results — workflow succeededValidated commit ✅ 556 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 51m 4s ⏱️ Max setup 3m 6s · max shard execution 17m 20s · max shard-job elapsed before upload 21m 6s · reporting 3s 🌐 207.94 requests/attempt · 2.82 app boots/UI scenario · 4.33% common-shard skew Optimization targets still in progress:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |



Summary
Backport of #32313 (fixes #32276) to the
2.0release branch.Math equations (
<block-math-equation>nodes) inserted via the BlockEditor's$$...$$syntax were silently stripped on save due to two independent sanitizer layers:sanitize.utils.ts) — DOMPurify strips unknown HTML tags. Applied the placeholder-protect pattern (with per-call nonce) already used for entity links: stash<block-math-equation>tags before sanitizing, restore after.DescriptionSanitizer.java) — OWASP HTML sanitizer uses an explicit allowlist. Addedblock-math-equationelement withmath_equationattribute (LaTeX, rendered client-side by KaTeX) andiseditingrestricted to"true"/"false".math-equation.less) — Fixed selection-state bug wherebackground-color: black+color: whitemade KaTeX text invisible when clicked.Changes backported
DescriptionSanitizer.java— allowblock-math-equationthrough OWASP sanitizerDescriptionSanitizerTest.java— 2 new test casessanitize.utils.ts— nonce-based placeholder protection for math equationssanitize.utils.test.ts— 3 new Jest casesmath-equation.less— fix selected-node color bugBlockEditorMathEquations.spec.ts— new Playwright E2E spec (save + reload round-trip)Test plan
sanitize.utils.test.ts— 13/13 passDescriptionSanitizerTest.java— 28/28 pass🤖 Generated with Claude Code