feat: more esacpe
This commit is contained in:
parent
a40d46b1a9
commit
4e9038519c
|
|
@ -156,7 +156,13 @@ export const stripHtmlValidation = (
|
|||
'strong',
|
||||
'u',
|
||||
'a',
|
||||
]);
|
||||
])
|
||||
.replace(/>/gi, '>')
|
||||
.replace(/</gi, '<')
|
||||
.replace(/&/gi, '&')
|
||||
.replace(/ /gi, ' ')
|
||||
.replace(/"/gi, '"')
|
||||
.replace(/'/gi, "'");
|
||||
}
|
||||
|
||||
if (type === 'markdown') {
|
||||
|
|
@ -168,6 +174,8 @@ export const stripHtmlValidation = (
|
|||
})
|
||||
.replace(/&/gi, '&')
|
||||
.replace(/ /gi, ' ')
|
||||
.replace(/"/gi, '"')
|
||||
.replace(/'/gi, "'")
|
||||
.replace(/<h2>([.\s\S]*?)<\/h2>/g, (match, p1) => {
|
||||
return `<h2>## ${p1}</h2>\n`;
|
||||
})
|
||||
|
|
@ -206,14 +214,14 @@ export const stripHtmlValidation = (
|
|||
const html = (value || '')
|
||||
.replace(/&/gi, '&')
|
||||
.replace(/ /gi, ' ')
|
||||
.replace(/"/gi, '"')
|
||||
.replace(/'/gi, "'")
|
||||
.replace(/^<p[^>]*>/i, '')
|
||||
.replace(/<p[^>]*>/gi, '\n')
|
||||
.replace(/<\/p>/gi, '')
|
||||
.replace(/>/gi, '>')
|
||||
.replace(/</gi, '<');
|
||||
.replace(/<\/p>/gi, '');
|
||||
|
||||
if (none) {
|
||||
return striptags(html);
|
||||
return striptags(html).replace(/>/gi, '>').replace(/</gi, '<');
|
||||
}
|
||||
|
||||
if (replaceBold) {
|
||||
|
|
@ -235,11 +243,15 @@ export const stripHtmlValidation = (
|
|||
convertMentionFunction
|
||||
);
|
||||
|
||||
return striptags(processedHtml);
|
||||
return striptags(processedHtml)
|
||||
.replace(/>/gi, '>')
|
||||
.replace(/</gi, '<');
|
||||
}
|
||||
|
||||
// Strip all other tags
|
||||
return striptags(html, ['ul', 'li', 'h1', 'h2', 'h3']);
|
||||
return striptags(html, ['ul', 'li', 'h1', 'h2', 'h3'])
|
||||
.replace(/>/gi, '>')
|
||||
.replace(/</gi, '<');
|
||||
};
|
||||
|
||||
export const convertMention = (
|
||||
|
|
|
|||
Loading…
Reference in New Issue