diff --git a/packages/overtype b/packages/overtype index ff2c832..3e48814 160000 --- a/packages/overtype +++ b/packages/overtype @@ -1 +1 @@ -Subproject commit ff2c8325c9d4e968098c6c46e6b0f5c877e8ab80 +Subproject commit 3e48814e9993e842f541dfe1186fb5b32378e536 diff --git a/src/lib/enhancers/github/github-common.ts b/src/lib/enhancers/github/github-common.ts index 796f70c..09f57ff 100644 --- a/src/lib/enhancers/github/github-common.ts +++ b/src/lib/enhancers/github/github-common.ts @@ -36,16 +36,28 @@ export function prepareGitHubHighlighter() { }) } +function escapeHtml(text: string): string { + const map: Record = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + } + return text.replace(/[&<>"']/g, (m) => map[m]!) +} + function githubHighlighter(code: string, language?: string) { try { if (language && hljs.getLanguage(language)) { const result = hljs.highlight(code, { language }) return result.value } else { - return code + // No language specified - escape HTML to prevent tags from being interpreted + return escapeHtml(code) } } catch (error) { console.warn("highlight.js highlighting failed:", error) - return code + return escapeHtml(code) } }