Skip to content

Commit

Permalink
fix: xml not render correctly (janhq#3743)
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur authored Sep 30, 2024
1 parent 7c63914 commit 87a8bc7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions web/screens/Thread/ThreadCenterPanel/SimpleTextMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {

const clipboard = useClipboard({ timeout: 1000 })

function escapeHtml(html: string): string {
return html
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;')
}

const marked: Marked = new Marked(
markedHighlight({
langPrefix: 'hljs',
Expand All @@ -69,6 +78,9 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
}),
{
renderer: {
html: (html: string) => {
return escapeHtml(html) // Escape any HTML
},
link: (href, title, text) => {
return Renderer.prototype.link
?.apply(this, [href, title, text])
Expand Down

0 comments on commit 87a8bc7

Please sign in to comment.