Skip to content

Commit ec57cac

Browse files
authored
fix(markdown): update the math renderer security patch (#10677)
1 parent 1944963 commit ec57cac

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎apps/sim/scripts/test-markdown-viewer-e2e.ts‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const source = [
101101
'~~~unrecognized-language\n<literal> & **not emphasis**\n~~~',
102102
' indented code',
103103
'## Diagram',
104-
'```mermaid\nflowchart LR\n A[Start] --> B[Validate] --> C[Finish]\n```',
104+
'```mermaid\nflowchart LR\n A[Start] --> B[Validate] --> C[Finish]\n B --> D["$$\\frac{1}{2}$$"]\n```',
105105
'## Images',
106106
'![Local image](/favicon/android-chrome-512x512.png)',
107107
'## Preserved source',
@@ -321,7 +321,22 @@ async function proveFeatures(page: Page) {
321321
),
322322
'Image exceeds the reading column'
323323
)
324-
await expect(page.locator('.mermaid-diagram-frame svg')).toBeAttached({ timeout: 30_000 })
324+
const diagram = page.locator('.mermaid-diagram-frame svg')
325+
await expect(diagram).toBeAttached({ timeout: 30_000 })
326+
const fraction = diagram.locator('math mfrac')
327+
await expect(fraction).toBeVisible()
328+
const fractionLayout = await fraction.evaluate((element) => {
329+
const numerator = element.children[0]?.getBoundingClientRect()
330+
const denominator = element.children[1]?.getBoundingClientRect()
331+
return numerator && denominator
332+
? { numeratorBottom: numerator.bottom, denominatorTop: denominator.top }
333+
: null
334+
})
335+
assert(fractionLayout, 'The diagram must render both parts of its fraction')
336+
assert(
337+
fractionLayout.numeratorBottom < fractionLayout.denominatorTop,
338+
'The diagram must typeset the fraction vertically instead of displaying raw math source'
339+
)
325340
await contained(page)
326341
}
327342

‎bun.lock‎

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
"hono": "4.13.18",
166166
"image-size": "2.0.4",
167167
"ip-address": "10.7.4",
168+
"katex": "0.18.2",
168169
"postcss": "8.5.32",
169170
"prosemirror-model": "1.25.12",
170171
"prosemirror-state": "1.4.4",

0 commit comments

Comments
 (0)