fix: xml not render correctly (#3743)
This commit is contained in:
parent
7c63914e64
commit
87a8bc7359
@ -53,6 +53,15 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
|
||||
|
||||
const clipboard = useClipboard({ timeout: 1000 })
|
||||
|
||||
function escapeHtml(html: string): string {
|
||||
return html
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
}
|
||||
|
||||
const marked: Marked = new Marked(
|
||||
markedHighlight({
|
||||
langPrefix: 'hljs',
|
||||
@ -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])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user