@ecency/render-helper 2.4.32 → 2.4.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +16 -17
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +18 -22
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +16 -20
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { DOMParser as DOMParser$1, XMLSerializer
|
|
1
|
+
import { DOMParser as DOMParser$1, XMLSerializer } from '@xmldom/xmldom';
|
|
2
2
|
import xss from 'xss';
|
|
3
3
|
import multihash from 'multihashes';
|
|
4
4
|
import querystring from 'querystring';
|
|
5
5
|
import { Remarkable } from 'remarkable';
|
|
6
6
|
import { linkify as linkify$1 } from 'remarkable/linkify';
|
|
7
|
-
import he2 from 'he';
|
|
8
7
|
import * as htmlparser2 from 'htmlparser2';
|
|
9
8
|
import * as domSerializerModule from 'dom-serializer';
|
|
10
9
|
import { LRUCache } from 'lru-cache';
|
|
10
|
+
import he from 'he';
|
|
11
11
|
|
|
12
12
|
// src/consts/white-list.const.ts
|
|
13
13
|
var WHITE_LIST = [
|
|
@@ -168,16 +168,13 @@ var ALLOWED_ATTRIBUTES = {
|
|
|
168
168
|
"del": [],
|
|
169
169
|
"ins": []
|
|
170
170
|
};
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
};
|
|
179
|
-
var DOMParser = hasDOMParser ? new globalThis.DOMParser() : new DOMParser$1({ onError: lenientErrorHandler });
|
|
180
|
-
var XMLSerializer = hasXMLSerializer ? globalThis.XMLSerializer : XMLSerializer$1;
|
|
171
|
+
function createParser() {
|
|
172
|
+
return new DOMParser$1({
|
|
173
|
+
onError(level, msg) {
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
var DOMParser = createParser();
|
|
181
178
|
|
|
182
179
|
// src/helper.ts
|
|
183
180
|
function removeDuplicateAttributes(html) {
|
|
@@ -1593,8 +1590,7 @@ function markdownToHTML(input, forApp, parentDomain = "ecency.com", seoContext,
|
|
|
1593
1590
|
traverse(doc, forApp, 0, { firstImageFound: false }, parentDomain, seoContext, renderOptions);
|
|
1594
1591
|
output = serializer.serializeToString(doc);
|
|
1595
1592
|
} catch (fallbackError) {
|
|
1596
|
-
|
|
1597
|
-
output = `<p dir="auto">${escapedContent}</p>`;
|
|
1593
|
+
output = sanitizeHtml(output || md.render(input));
|
|
1598
1594
|
}
|
|
1599
1595
|
}
|
|
1600
1596
|
if (forApp && output && entityPlaceholders.length > 0) {
|
|
@@ -1603,7 +1599,7 @@ function markdownToHTML(input, forApp, parentDomain = "ecency.com", seoContext,
|
|
|
1603
1599
|
output = output.split(placeholder).join(entity);
|
|
1604
1600
|
});
|
|
1605
1601
|
}
|
|
1606
|
-
output = output.replace(/ xmlns="http:\/\/www.w3.org\/1999\/xhtml"/g, "").replace('<body id="root">', "").replace("</body>", "").trim();
|
|
1602
|
+
output = output.replace(/ xmlns="http:\/\/www.w3.org\/1999\/xhtml"/g, "").replace(/^<\?xml[^?]*\?>/, "").replace(/^<!DOCTYPE[^>]*>/i, "").replace(/<\/?html[^>]*>/g, "").replace(/<head[^>]*>[\s\S]*?<\/head>/g, "").replace('<body id="root">', "").replace("</body>", "").trim();
|
|
1607
1603
|
return sanitizeHtml(output);
|
|
1608
1604
|
}
|
|
1609
1605
|
var mdInstance = null;
|
|
@@ -1665,7 +1661,7 @@ function getImage(entry, width = 0, height = 0, format = "match") {
|
|
|
1665
1661
|
}
|
|
1666
1662
|
}
|
|
1667
1663
|
if (meta && typeof meta.image === "string" && meta.image.length > 0) {
|
|
1668
|
-
const decodedImage =
|
|
1664
|
+
const decodedImage = he.decode(meta.image);
|
|
1669
1665
|
if (isGifLink(decodedImage)) {
|
|
1670
1666
|
return proxifyImageSrc(decodedImage, 0, 0, format);
|
|
1671
1667
|
}
|
|
@@ -1673,7 +1669,7 @@ function getImage(entry, width = 0, height = 0, format = "match") {
|
|
|
1673
1669
|
}
|
|
1674
1670
|
if (meta && meta.image && !!meta.image.length && meta.image[0]) {
|
|
1675
1671
|
if (typeof meta.image[0] === "string") {
|
|
1676
|
-
const decodedImage =
|
|
1672
|
+
const decodedImage = he.decode(meta.image[0]);
|
|
1677
1673
|
if (isGifLink(decodedImage)) {
|
|
1678
1674
|
return proxifyImageSrc(decodedImage, 0, 0, format);
|
|
1679
1675
|
}
|
|
@@ -1695,7 +1691,7 @@ function getImage(entry, width = 0, height = 0, format = "match") {
|
|
|
1695
1691
|
if (!src) {
|
|
1696
1692
|
return null;
|
|
1697
1693
|
}
|
|
1698
|
-
const decodedSrc =
|
|
1694
|
+
const decodedSrc = he.decode(src);
|
|
1699
1695
|
if (isGifLink(decodedSrc)) {
|
|
1700
1696
|
return proxifyImageSrc(decodedSrc, 0, 0, format);
|
|
1701
1697
|
}
|
|
@@ -1716,7 +1712,7 @@ function catchPostImage(obj, width = 0, height = 0, format = "match") {
|
|
|
1716
1712
|
if (!src) {
|
|
1717
1713
|
return null;
|
|
1718
1714
|
}
|
|
1719
|
-
const decodedSrc =
|
|
1715
|
+
const decodedSrc = he.decode(src);
|
|
1720
1716
|
if (isGifLink(decodedSrc)) {
|
|
1721
1717
|
return proxifyImageSrc(decodedSrc, 0, 0, format);
|
|
1722
1718
|
}
|
|
@@ -1809,7 +1805,7 @@ function postBodySummary(entryBody, length = 200, platform = "web") {
|
|
|
1809
1805
|
text2 = joint(text2.split(" "), length);
|
|
1810
1806
|
}
|
|
1811
1807
|
if (text2) {
|
|
1812
|
-
text2 =
|
|
1808
|
+
text2 = he.decode(text2);
|
|
1813
1809
|
}
|
|
1814
1810
|
return text2;
|
|
1815
1811
|
}
|