@ecency/render-helper 2.2.35 → 2.2.37
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/consts/regexes.const.js +1 -1
- package/lib/consts/regexes.const.js.map +1 -1
- package/lib/proxify-image-src.d.ts +1 -0
- package/lib/proxify-image-src.js +11 -2
- package/lib/proxify-image-src.js.map +1 -1
- package/lib/render-helper.js +1 -1
- package/package.json +1 -1
- package/src/consts/regexes.const.ts +1 -1
- package/src/proxify-image-src.ts +10 -1
- package/src/test/data/legacy/10.json +1 -1
- package/src/test/data/legacy/23.json +1 -1
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ export const TWITCH_REGEX = /https?:\/\/(?:www.)?twitch.tv\/(?:(videos)\/)?([a-z
|
|
|
23
23
|
export const DAPPLR_REGEX = /^(https?:)?\/\/[a-z]*\.dapplr.in\/file\/dapplr-videos\/.*/i
|
|
24
24
|
export const TRUVVL_REGEX = /^https?:\/\/embed.truvvl.com\/(@[\w.\d-]+)\/(.*)/i
|
|
25
25
|
export const LBRY_REGEX = /^(https?:)?\/\/lbry.tv\/\$\/embed\/.*/i
|
|
26
|
-
export const ODYSEE_REGEX = /^(https?:)?\/\/odysee.com
|
|
26
|
+
export const ODYSEE_REGEX = /^(https?:)?\/\/odysee.com\/.*/i
|
|
27
27
|
export const SKATEHIVE_IPFS_REGEX = /^https?:\/\/ipfs\.skatehive\.app\/ipfs\/([^/?#]+)/i
|
|
28
28
|
export const ARCH_REGEX = /^(https?:)?\/\/archive.org\/embed\/.*/i
|
|
29
29
|
export const SPEAK_REGEX = /(?:https?:\/\/(?:3speak.([a-z]+)\/watch\?v=)|(?:3speak.([a-z]+)\/embed\?v=))([A-Za-z0-9\_\-\.\/]+)(&.*)?/i
|
package/src/proxify-image-src.ts
CHANGED
|
@@ -15,13 +15,22 @@ export function extractPHash(url: string): string | null {
|
|
|
15
15
|
return null
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
export function isValidUrl(url: string): boolean {
|
|
19
|
+
try {
|
|
20
|
+
return Boolean(new URL(url));
|
|
21
|
+
}
|
|
22
|
+
catch(e){
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
18
27
|
export function getLatestUrl(str: string): string {
|
|
19
28
|
const [last] = [...str.replace(/https?:\/\//g, '\n$&').trim().split('\n')].reverse()
|
|
20
29
|
return last
|
|
21
30
|
}
|
|
22
31
|
|
|
23
32
|
export function proxifyImageSrc(url?: string, width = 0, height = 0, format = 'match') {
|
|
24
|
-
if (!url || typeof url !== 'string') {
|
|
33
|
+
if (!url || typeof url !== 'string' || !isValidUrl(url)) {
|
|
25
34
|
return ''
|
|
26
35
|
}
|
|
27
36
|
|
|
@@ -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": "<p dir=\"auto\">Lorem ipsum dolor <img
|
|
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": 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": "<p dir=\"auto\"><IMG SRC=/ onerror=\"alert(String.fromCharCode(88,83,83))\"> <img
|
|
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
|
}
|