Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(deps): update dependency markdown-it to v15 (#21843)

renovate[bot]0de2bd34ea81
diff --git a/frontend/package.json b/frontend/package.json
index 83b7de87b4..2b14081c86 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -56,7 +56,7 @@
"lossless-json": "^4.3.0",
"lucide-react": "^1.14.0",
"lucide-static": "^1.14.0",
- "markdown-it": "^14.1.0",
+ "markdown-it": "^15.0.0",
"monaco-editor": "npm:@codingame/[email protected]",
"normalize-wheel": "^1.0.1",
"posthog-js": "^1.406.2",
@@ -102,7 +102,6 @@
"@types/file-saver": "^2.0.7",
"@types/jsdom": "28.0.3",
"@types/lodash-es": "4.17.12",
- "@types/markdown-it": "^14.1.2",
"@types/mdast": "^4.0.4",
"@types/node": "24.19.2",
"@types/normalize-wheel": "^1.0.4",
diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml
index e4a2158d88..381f81626f 100644
--- a/frontend/pnpm-lock.yaml
+++ b/frontend/pnpm-lock.yaml
@@ -293,8 +293,8 @@ importers:
specifier: ^1.14.0
version: 1.66.0
markdown-it:
- specifier: ^14.1.0
- version: 14.3.3
+ specifier: ^15.0.0
+ version: 15.0.3
monaco-editor:
specifier: npm:@codingame/[email protected]
version: '@codingame/[email protected]'
@@ -425,9 +425,6 @@ importers:
'@types/lodash-es':
specifier: 4.17.12
version: 4.17.12
- '@types/markdown-it':
- specifier: ^14.1.2
- version: 14.2.0
'@types/mdast':
specifier: ^4.0.4
version: 4.0.4
@@ -2029,24 +2026,15 @@ packages:
resolution: {integrity: sha512-/HQ2uFoetFTXuye8vzIcHw2z6Fwi7Hi/qcgC+RoS9NCyewiqxhVGqlG+ViGB6lkax481R6dmhf1I7lIGlzJStQ==}
- '@types/[email protected]':
- resolution: {integrity: sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==}
-
resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==}
resolution: {integrity: sha512-FOvQ0YPD5NOfPgMzJihoT+Za5pdkDJWcbpuj1DjaKZIr/gxodQjY/uWEFlTNqW2ugXHUiL8lRQgw63dzKHZdeQ==}
- '@types/[email protected]':
- resolution: {integrity: sha512-NoQ2yGlLWj4wpxMs+TYmRKk3thDrQ97agr7sFqfLsAlvoS8SNQuTrlObhFqG9iugdTtgOE9jpJ6FNM4ZGsa5xQ==}
-
resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==}
- '@types/[email protected]':
- resolution: {integrity: sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==}
-
resolution: {integrity: sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==}
@@ -2549,10 +2537,6 @@ packages:
resolution: {integrity: sha512-PwKooW9JUzh5chmYfHM3IQl5OkK2u2Nm011MgeZrss3JmFraUx/fqrf78kk8GUMYoibx/14MdwTl/1WKkG7TpQ==}
engines: {node: '>=10.13.0'}
- resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
- engines: {node: '>=0.12'}
-
resolution: {integrity: sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==}
engines: {node: '>=0.12'}
@@ -2561,6 +2545,10 @@ packages:
resolution: {integrity: sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA==}
engines: {node: '>=20.19.0'}
+ resolution: {integrity: sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==}
+ engines: {node: '>=20.19.0'}
+
resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==}
engines: {node: '>= 0.4'}
@@ -2974,8 +2962,8 @@ packages:
resolution: {integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==}
engines: {node: '>= 12.0.0'}
- resolution: {integrity: sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==}
+ resolution: {integrity: sha512-wJ/TwpSDTLepCrQoYWYIExIKg5Zchex2Nn5yk2mFnB+6PtdkHtyLx742md9csRjjOnGkKIS/RrbY7l8D6gT9Vw==}
resolution: {integrity: sha512-J8xewKD/Gk22OZbhpOVSwcs60zhd95ESDwezOFuA3/099925PdHJ7OFHNTGtajL3AlZkykD32HykiMo+BIBI8A==}
@@ -3022,8 +3010,8 @@ packages:
resolution: {integrity: sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==}
- resolution: {integrity: sha512-L//tDAkjTjJCU6pBUSBTgs3Kg4InVaZuUZog/b6V12UKhcDQ7S78877ibbCanRExwPuYP1CZD7Gd2dxSy1GXRg==}
+ resolution: {integrity: sha512-+Az7Ojz3iRGu8KYMvJ6xVhvrxP3eE+vEtJX75Ow88XBpcQNV/0lGX5ZynIIBftREo4DC2jsveAMDaeltmm8QvQ==}
hasBin: true
@@ -3086,8 +3074,8 @@ packages:
resolution: {integrity: sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==}
- resolution: {integrity: sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==}
+ resolution: {integrity: sha512-1+HBaOx0zi/dQWht8rNv9MYf9qqpqL/kxI0hXImU6Y547zM6Sni8BQibt7ifgMcYtQg41ao3Ivd6cnSM86inpg==}
resolution: {integrity: sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q==}
@@ -3714,8 +3702,8 @@ packages:
engines: {node: '>=16.20.0'}
hasBin: true
- resolution: {integrity: sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==}
+ resolution: {integrity: sha512-U3PppEkleoTnIfi8BozMx3yju3qc/L6SwqWo2Sw+54PX+PX0q9I+r1Um5HCmqD7n9VDX5/v3vQH/AjA6deDdtw==}
resolution: {integrity: sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==}
@@ -5485,25 +5473,16 @@ snapshots:
parse5: 8.0.1
undici-types: 7.28.0
- '@types/[email protected]': {}
-
dependencies:
'@types/lodash': 4.17.21
'@types/[email protected]': {}
- '@types/[email protected]':
- dependencies:
- '@types/linkify-it': 5.0.0
- '@types/mdurl': 2.0.0
-
dependencies:
'@types/unist': 3.0.3
- '@types/[email protected]': {}
-
'@types/[email protected]': {}
@@ -5923,12 +5902,12 @@ snapshots:
graceful-fs: 4.2.11
tapable: 2.3.3
-
+
@@ -6297,9 +6276,9 @@ snapshots:
lightningcss-win32-arm64-msvc: 1.33.0
lightningcss-win32-x64-msvc: 1.33.0
dependencies:
- uc.micro: 2.1.0
+ uc.micro: 3.0.0
@@ -6337,14 +6316,14 @@ snapshots:
dependencies:
'@jridgewell/sourcemap-codec': 1.6.0
dependencies:
- argparse: 2.0.1
- entities: 4.5.0
- linkify-it: 5.0.2
- mdurl: 2.0.0
+ argparse: 3.0.4
+ entities: 8.1.0
+ linkify-it: 6.1.0
+ mdurl: 2.1.0
punycode.js: 2.3.1
- uc.micro: 2.1.0
+ uc.micro: 3.0.0
@@ -6507,7 +6486,7 @@ snapshots:
@@ -7296,7 +7275,7 @@ snapshots:
'@typescript/typescript-win32-arm64': 7.0.2
'@typescript/typescript-win32-x64': 7.0.2
diff --git a/frontend/src/components/MarkdownEditor/MarkdownEditor.test.tsx b/frontend/src/components/MarkdownEditor/MarkdownEditor.test.tsx
index bfbdca117c..d2ee28b65e 100644
--- a/frontend/src/components/MarkdownEditor/MarkdownEditor.test.tsx
+++ b/frontend/src/components/MarkdownEditor/MarkdownEditor.test.tsx
@@ -107,6 +107,32 @@ describe("MarkdownEditor", () => {
unmount();
});
+ test.each([{ untrusted: false }, { untrusted: true }])(
+ "links a bare host written without a scheme (untrusted: $untrusted)",
+ ({ untrusted }) => {
+ const { container, render, unmount } = renderIntoContainer(
+ <MarkdownEditor
+ content="see www.example.com/docs and example.com"
+ mode="preview"
+ untrusted={untrusted}
+ />
+ );
+
+ render();
+
+ const links = Array.from(container.querySelectorAll("a")).map((link) => [
+ link.textContent,
+ link.getAttribute("href"),
+ ]);
+ expect(links).toEqual([
+ ["www.example.com/docs", "http://www.example.com/docs"],
+ ["example.com", "http://example.com"],
+ ]);
+
+ unmount();
+ }
+ );
+
test("renders untrusted images and raw HTML without resource-loading elements or attributes", () => {
const { container, render, unmount } = renderIntoContainer(
<MarkdownEditor
diff --git a/frontend/src/components/MarkdownEditor/MarkdownEditor.tsx b/frontend/src/components/MarkdownEditor/MarkdownEditor.tsx
index 7871367fe7..2df9b10a55 100644
--- a/frontend/src/components/MarkdownEditor/MarkdownEditor.tsx
+++ b/frontend/src/components/MarkdownEditor/MarkdownEditor.tsx
@@ -1,7 +1,9 @@
import DOMPurify from "dompurify";
import { Bold, Code2, Hash, Heading1, Link2 } from "lucide-react";
-import MarkdownIt from "markdown-it";
-import type Token from "markdown-it/lib/token.mjs";
+import MarkdownIt, {
+ type MarkdownIt as MarkdownItInstance,
+ type Token,
+} from "markdown-it";
import { type ReactNode, useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
@@ -10,10 +12,20 @@ import { Textarea } from "@/components/ui/textarea";
import "./MarkdownEditor.css";
import { cn } from "@/lib/utils";
-const markdown = new MarkdownIt({
- html: true,
- linkify: true,
-});
+// linkify-it leaves fuzzy links off, so a bare host such as www.example.com
+// renders as plain text. Comments and descriptions are written that way, so
+// every renderer here keeps those clickable.
+function linkifyBareHosts(md: MarkdownItInstance): MarkdownItInstance {
+ md.linkify.set({ fuzzyLink: true });
+ return md;
+}
+
+const markdown = linkifyBareHosts(
+ new MarkdownIt({
+ html: true,
+ linkify: true,
+ })
+);
// Displaying untrusted text must not request a remote URL: an image URL
// derived from SQL or schema text would carry that text to another server
@@ -22,13 +34,15 @@ const markdown = new MarkdownIt({
// that the reader may choose to follow. Without a source, or inside a link
// where anchors cannot nest, the label stays plain text. The page turns DNS
// prefetching off in index.html, so no link resolves its host until clicked.
-const untrustedMarkdown = new MarkdownIt({
- html: false,
- linkify: true,
-});
+const untrustedMarkdown = linkifyBareHosts(
+ new MarkdownIt({
+ html: false,
+ linkify: true,
+ })
+);
untrustedMarkdown.renderer.rules.image = (tokens, idx) => {
const { escapeHtml } = untrustedMarkdown.utils;
- const src = tokens[idx].attrGet("src") ?? "";
+ const src = String(tokens[idx].attrGet("src") ?? "");
const alt = labelText(tokens[idx].children ?? []);
const linkDepth = tokens
.slice(0, idx)