mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-24 00:38:49 +01:00
Fix bug when text nodes contain HTML <>
Text nodes don't escape them
This commit is contained in:
parent
b9c762cf53
commit
d0579a57d6
1 changed files with 2 additions and 2 deletions
|
@ -20,7 +20,7 @@ function enhanceContent(content, opts = {}) {
|
|||
// Convert :shortcode: to <img />
|
||||
let textNodes = extractTextNodes(dom);
|
||||
textNodes.forEach((node) => {
|
||||
let html = node.nodeValue;
|
||||
let html = node.nodeValue.replace(/</g, '<').replace(/>/g, '>');
|
||||
if (emojis) {
|
||||
html = emojifyText(html, emojis);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ function enhanceContent(content, opts = {}) {
|
|||
// Convert `code` to <code>code</code>
|
||||
textNodes = extractTextNodes(dom);
|
||||
textNodes.forEach((node) => {
|
||||
let html = node.nodeValue;
|
||||
let html = node.nodeValue.replace(/</g, '<').replace(/>/g, '>');
|
||||
if (/`[^`]+`/g.test(html)) {
|
||||
html = html.replaceAll(/(`[^]+?`)/g, '<code>$1</code>');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue