Skip to content

Commit

Permalink
Merge pull request #151 from calebeby/escape-html-in-error
Browse files Browse the repository at this point in the history
Escape HTML in error message/recommendation
  • Loading branch information
orta authored Apr 20, 2022
2 parents 1f3399c + aa047ea commit 78bebc3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-colts-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"remark-shiki-twoslash": patch
---

Escape HTML in error message/recommendation
6 changes: 3 additions & 3 deletions packages/remark-shiki-twoslash/src/exceptionMessageDOM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ export const setupNodeForTwoslashException = (code: string, node: Node, error: u

const bodyFromTwoslashError = (error: TwoslashError) => {
return `
<h3>${error.title}</h3>
<p>${error.description.replace(/(?:\r\n|\r|\n)/g, '<br>')}</p>
<code>${error.recommendation.replace(/(?:\r\n|\r|\n)/g, '<br>')}</code>
<h3>${escapeHtml(error.title)}</h3>
<p>${escapeHtml(error.description).replace(/(?:\r\n|\r|\n)/g, "<br>")}</p>
<code>${escapeHtml(error.recommendation).replace(/(?:\r\n|\r|\n)/g, "<br>")}</code>
`
}

Expand Down

0 comments on commit 78bebc3

Please sign in to comment.