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 })
|
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(
|
const marked: Marked = new Marked(
|
||||||
markedHighlight({
|
markedHighlight({
|
||||||
langPrefix: 'hljs',
|
langPrefix: 'hljs',
|
||||||
@ -69,6 +78,9 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
|
|||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
renderer: {
|
renderer: {
|
||||||
|
html: (html: string) => {
|
||||||
|
return escapeHtml(html) // Escape any HTML
|
||||||
|
},
|
||||||
link: (href, title, text) => {
|
link: (href, title, text) => {
|
||||||
return Renderer.prototype.link
|
return Renderer.prototype.link
|
||||||
?.apply(this, [href, title, text])
|
?.apply(this, [href, title, text])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user