mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-26 11:15:43 +03:00
Quick fix html escaping bug
This commit is contained in:
parent
4aeaeb229c
commit
d95ef309ca
1 changed files with 12 additions and 3 deletions
|
@ -41,7 +41,10 @@ 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.replace(/</g, '<').replace(/>/g, '>');
|
let html = node.nodeValue
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>');
|
||||||
if (emojis) {
|
if (emojis) {
|
||||||
html = emojifyText(html, emojis);
|
html = emojifyText(html, emojis);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +109,10 @@ 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.replace(/</g, '<').replace(/>/g, '>');
|
let html = node.nodeValue
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.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>');
|
||||||
}
|
}
|
||||||
|
@ -122,7 +128,10 @@ function enhanceContent(content, opts = {}) {
|
||||||
rejectFilter: ['A'],
|
rejectFilter: ['A'],
|
||||||
});
|
});
|
||||||
textNodes.forEach((node) => {
|
textNodes.forEach((node) => {
|
||||||
let html = node.nodeValue.replace(/</g, '<').replace(/>/g, '>');
|
let html = node.nodeValue
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>');
|
||||||
if (/@[a-zA-Z0-9_]+@twitter\.com/g.test(html)) {
|
if (/@[a-zA-Z0-9_]+@twitter\.com/g.test(html)) {
|
||||||
html = html.replaceAll(
|
html = html.replaceAll(
|
||||||
/(@([a-zA-Z0-9_]+)@twitter\.com)/g,
|
/(@([a-zA-Z0-9_]+)@twitter\.com)/g,
|
||||||
|
|
Loading…
Reference in a new issue