Skip to content

Commit 933dcda

Browse files
committed
Escape HTML in href attribute
1 parent 98d0e12 commit 933dcda

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/lib/utils/marked.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function addInlineCitations(md: string, webSearchSources: SimpleSource[] = []):
194194
if (index === 0) return false;
195195
const source = webSearchSources[index - 1];
196196
if (source) {
197-
return `<a href="${source.link}" target="_blank" rel="noreferrer" style="${linkStyle}">${index}</a>`;
197+
return `<a href="${escapeHTML(source.link)}" target="_blank" rel="noreferrer" style="${linkStyle}">${index}</a>`;
198198
}
199199
return "";
200200
})
@@ -235,7 +235,7 @@ function createMarkedInstance(sources: SimpleSource[]): Marked {
235235
link: (href, title, text) => {
236236
const safeHref = sanitizeHref(href);
237237
return safeHref
238-
? `<a href="${safeHref}" target="_blank" rel="noreferrer">${text}</a>`
238+
? `<a href="${escapeHTML(safeHref)}" target="_blank" rel="noreferrer">${text}</a>`
239239
: `<span>${escapeHTML(text ?? "")}</span>`;
240240
},
241241
html: (html) => escapeHTML(html),

0 commit comments

Comments
 (0)