Repository navigation
Fixes #32276: preserve math equations through frontend and backend sanitizers - #32313
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]>
|
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! |
✅ Playwright Results — workflow succeededValidated commit ✅ 550 passed · ❌ 0 failed · 🟡 2 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) 52m 15s ⏱️ Max setup 4m 14s · max shard execution 16m 33s · max shard-job elapsed before upload 20m 5s · reporting 7s 🌐 218.62 requests/attempt · 2.82 app boots/UI scenario · 11.38% common-shard skew Optimization targets still in progress:
🟡 2 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
|
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! |
…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]>
|
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 ✅ Approved 1 resolved / 1 findingsPreserves math equations through frontend and backend sanitizers using placeholder protection and allowlist updates. A potential collision issue with the restore logic was fixed to prevent LaTeX content containing '$' from being corrupted. ✅ 1 resolved✅ Bug: Math equation restore corrupts LaTeX containing '$'
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 |
|
🚦 Removed from the merge queue —
|
… sanitizers (1.13) (#32402) * Fixes #32276: preserve math equations through frontend and backend sanitizers 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]> * fix(sanitize): nonce-based placeholders + function replacer for math 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]> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]>
…nitizers (#32313) * Fixes #32276: preserve math equations through frontend and backend sanitizers 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]> * fix(sanitize): nonce-based placeholders + function replacer for math 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]> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]>
…backend sanitizers (#32509) * Fixes #32276: preserve math equations through frontend and backend sanitizers 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]> * fix(sanitize): nonce-based placeholders + function replacer for math 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]> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]>
…nd backend sanitizers (open-metadata#32313) * Fixes open-metadata#32276: preserve math equations through frontend and backend sanitizers 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]> * fix(sanitize): nonce-based placeholders + function replacer for math 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]> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]>



Describe your changes:
Fixes #32276
Math equations inserted via the BlockEditor's
MathEquationnode ($$...$$syntax) rendered correctly during editing but were silently stripped on save. The bug existed in two independent layers:sanitize.utils.ts) — DOMPurify strips unknown HTML tags by default. Applied the same placeholder-protect pattern already used for entity links: stash<block-math-equation>tags before sanitizing, restore after.DescriptionSanitizer.java) — The OWASP HTML sanitizer uses an explicit allowlist. Addedblock-math-equationelement withmath_equation(any LaTeX value, rendered client-side by KaTeX — not executable) andisediting(restricted to"true"/"false"only).math-equation.less) — Fixed a selection-state bug wherebackground-color: black+color: whitemade KaTeX text invisible when the node was clicked, and addeduser-select: noneto prevent the browser's native text-selection highlight from washing out the rendered equation.Type of change:
High-level design:
Both sanitizers (frontend DOMPurify and backend OWASP) independently strip any HTML tag not on their respective allowlists. The
<block-math-equation>custom tag used by Tiptap'sMathEquationextension fell through both. The fix mirrors the existing entity-link placeholder strategy in both layers rather than weakening the sanitizers' overall policies. Theiseditingattribute is gated to boolean strings only;math_equationis allowed freely because LaTeX content is text rendered by KaTeX — it cannot execute JavaScript.Tests:
Use cases covered
$$x^2$$syntax persists after save and page reloadblock-math-equationtag withmath_equationattribute survives both sanitizersiseditingattribute with a non-boolean value (XSS attempt) is stripped by backendUnit tests
src/utils/sanitize.utils.test.ts— 3 new cases added (standalone tag, mixed HTML, alongside entity links). 13/13 tests pass.DescriptionSanitizerTest.java— 2 new cases added (element preserved, non-booleaniseditingrejected). 28/28 tests pass.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
playwright/e2e/Features/BlockEditorMathEquations.spec.ts$$x^2 + y^2 = z^2$$into the description editor to trigger the Tiptap input ruleblock-math-equationnode is created in the editor before savingasset-description-containerManual testing performed
$$x^2 + y^2 = z^2$$— equation node rendered correctly in editor<block-math-equation ...>(not stripped by frontend)UI screen recording / screenshots:
TODO: attach screen recording showing equation entry → save → reload round-trip. Opening as draft until recording is attached.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #32276above.Greptile Summary
The PR preserves BlockEditor math equations across frontend and backend sanitization and improves their selected-state styling.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR A[BlockEditor math equation] --> B[Frontend placeholder protection] B --> C[DOMPurify sanitization] C --> D[Restore protected markup] D --> E[PATCH description] E --> F[Backend allowlist sanitizer] F --> G[Persist description] G --> H[Reload and render equation]Reviews (2): Last reviewed commit: "fix(sanitize): nonce-based placeholders ..." | Re-trigger Greptile