Fix bug when text nodes contain HTML <>
Text nodes don't escape them
This commit is contained in:
parent
b9c762cf53
commit
d0579a57d6
|
@ -20,7 +20,7 @@ function enhanceContent(content, opts = {}) {
|
||||||
// Convert :shortcode: to <img />
|
// Convert :shortcode: to <img />
|
||||||
let textNodes = extractTextNodes(dom);
|
let textNodes = extractTextNodes(dom);
|
||||||
textNodes.forEach((node) => {
|
textNodes.forEach((node) => {
|
||||||
let html = node.nodeValue;
|
let html = node.nodeValue.replace(/</g, '<').replace(/>/g, '>');
|
||||||
if (emojis) {
|
if (emojis) {
|
||||||
html = emojifyText(html, emojis);
|
html = emojifyText(html, emojis);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ function enhanceContent(content, opts = {}) {
|
||||||
// Convert `code` to <code>code</code>
|
// Convert `code` to <code>code</code>
|
||||||
textNodes = extractTextNodes(dom);
|
textNodes = extractTextNodes(dom);
|
||||||
textNodes.forEach((node) => {
|
textNodes.forEach((node) => {
|
||||||
let html = node.nodeValue;
|
let html = node.nodeValue.replace(/</g, '<').replace(/>/g, '>');
|
||||||
if (/`[^`]+`/g.test(html)) {
|
if (/`[^`]+`/g.test(html)) {
|
||||||
html = html.replaceAll(/(`[^]+?`)/g, '<code>$1</code>');
|
html = html.replaceAll(/(`[^]+?`)/g, '<code>$1</code>');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue