@ecency/render-helper 2.3.0 → 2.3.2
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/lib/methods/clean-reply.method.js +2 -1
- package/lib/methods/clean-reply.method.js.map +1 -1
- package/lib/methods/img.method.js +2 -4
- package/lib/methods/img.method.js.map +1 -1
- package/lib/render-helper.js +1 -1
- package/package.json +1 -1
- package/src/methods/clean-reply.method.ts +1 -0
- package/src/methods/img.method.ts +3 -5
- package/src/test/data/legacy/10.json +1 -1
- package/src/test/data/legacy/21.json +1 -1
- package/src/test/data/legacy/22.json +1 -1
- package/src/test/data/legacy/23.json +1 -1
- package/src/test/data/legacy/26.json +1 -1
package/package.json
CHANGED
|
@@ -28,4 +28,5 @@ export function cleanReply(s: string): string {
|
|
|
28
28
|
.replace('Posted via <a href="https://d.buzz" data-link="promote-link">D.Buzz</a>', '')
|
|
29
29
|
.replace('<div class="pull-right"><a href="/@hive.engage"></a></div>', '')
|
|
30
30
|
.replace('<div><a href="https://engage.hivechain.app"></a></div>', '')
|
|
31
|
+
.replace(`<div class="text-center"><img src="https://cdn.steemitimages.com/DQmNp6YwAm2qwquALZw8PdcovDorwaBSFuxQ38TrYziGT6b/A-20.png"><a href="https://bit.ly/actifit-app"><img src="https://cdn.steemitimages.com/DQmQqfpSmcQtfrHAtzfBtVccXwUL9vKNgZJ2j93m8WNjizw/l5.png"></a><a href="https://bit.ly/actifit-ios"><img src="https://cdn.steemitimages.com/DQmbWy8KzKT1UvCvznUTaFPw6wBUcyLtBT5XL9wdbB7Hfmn/l6.png"></a></div>`, '')
|
|
31
32
|
}
|
|
@@ -4,7 +4,7 @@ export function img(el: HTMLElement, webp: boolean): void {
|
|
|
4
4
|
el.removeAttribute("width");
|
|
5
5
|
el.removeAttribute("height");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
let src = el.getAttribute("src") || "";
|
|
8
8
|
|
|
9
9
|
// Normalize encoded characters
|
|
10
10
|
const decodedSrc = decodeURIComponent(
|
|
@@ -15,16 +15,14 @@ export function img(el: HTMLElement, webp: boolean): void {
|
|
|
15
15
|
// ❌ Remove if javascript or empty/invalid
|
|
16
16
|
const isInvalid = !src || decodedSrc.startsWith("javascript") || decodedSrc.startsWith("vbscript") || decodedSrc === "x";
|
|
17
17
|
if (isInvalid) {
|
|
18
|
-
|
|
19
|
-
return;
|
|
18
|
+
src = ""
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
// ❌ Skip relative paths (e.g., `photo.jpg`)
|
|
23
22
|
const isRelative = !/^https?:\/\//i.test(src) && !src.startsWith("/");
|
|
24
23
|
if (isRelative) {
|
|
25
24
|
console.warn("Skipped relative image:", src);
|
|
26
|
-
|
|
27
|
-
return;
|
|
25
|
+
src = ""
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
// Sanitize any dynamic or low-res src-like attributes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": 10,
|
|
3
3
|
"input": "Lorem ipsum dolor <img src=x onerror=alert(x)> sit amet.\n\n<a href=\"javascript:void(0)\">etiam ut sollicitudin neque</a>\n\n<a onclick=\"console.log('ss')\">Vivamus pulvinar semper porttitor</a>",
|
|
4
|
-
"result": ""
|
|
4
|
+
"result": "<p dir=\"auto\">Lorem ipsum dolor <img /> sit amet.</p>\n<p dir=\"auto\"><a>etiam ut sollicitudin neque</a></p>\n<p dir=\"auto\"><a>Vivamus pulvinar semper porttitor</a></p>"
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": 21,
|
|
3
3
|
"input": "javascript:/*--></title></style></textarea></script></xmp><svg/onload='+/\"/+/onmouseover=1/+/[*/[]/+alert(1)//'>\n\n<IMG SRC=\"javascript:alert('XSS');\"><img src=\"javascript:alert('XSS');\">\n\n<IMG SRC=javascript:alert('XSS')> <img src=javascript:alert('XSS')>",
|
|
4
|
-
"result": ""
|
|
4
|
+
"result": "<p dir=\"auto\">javascript:/<em>--><svg/onload='+/\"/+/onmouseover=1/+/[</em>/[]/+alert(1)//'></p>\n<p dir=\"auto\"><img /><img /></p>\n<p dir=\"auto\"><IMG SRC=javascript:alert('XSS')> <img src=javascript:alert('XSS')></p>"
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": 22,
|
|
3
3
|
"input": "<IMG SRC=JaVaScRiPt:alert('XSS')> <IMG SRC=javascript:alert("XSS")>\n<IMG SRC=`javascript:alert(\"RSnake says, 'XSS'\")`>\n<a onmouseover=\"alert(document.cookie)\">xxs link</a><a onmouseover=alert(document.cookie)>xxs link</a>\n<IMG \"\"\"><SCRIPT>alert(\"XSS\")</SCRIPT>\"><IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>\n <IMG SRC= onmouseover=\"alert('xxs')\">",
|
|
4
|
-
"result": ""
|
|
4
|
+
"result": "<p dir=\"auto\"><IMG SRC=JaVaScRiPt:alert('XSS')> <IMG SRC=javascript:alert("XSS")><br />\n<IMG SRC=<code>javascript:alert(\"RSnake says, 'XSS'\")</code>><br />\n<a>xxs link</a><a>xxs link</a><br />\n<IMG \"\"\">alert("XSS")\"><img /><br />\n<IMG SRC= onmouseover=\"alert('xxs')\"></p>"
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": 23,
|
|
3
3
|
"input": "<IMG SRC=/ onerror=\"alert(String.fromCharCode(88,83,83))\"></img> <img src=x onerror=\"javascript:alert('XSS')\"> <IMG SRC=javascript:alert('XSS')> <IMG SRC=javascript:alert('XSS')> <IMG SRC=\"  javascript:alert('XSS');\">",
|
|
4
|
-
"result": ""
|
|
4
|
+
"result": "<p dir=\"auto\"><IMG SRC=/ onerror=\"alert(String.fromCharCode(88,83,83))\"> <img /> <IMG SRC=javascript:alert('XSS')> <img /> <img /></p>"
|
|
5
5
|
}
|