@ecency/render-helper 2.2.13 → 2.2.14
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/catch-post-image.js +7 -7
- package/lib/catch-post-image.js.map +1 -1
- package/lib/consts/regexes.const.d.ts +1 -0
- package/lib/consts/regexes.const.js +2 -1
- package/lib/consts/regexes.const.js.map +1 -1
- package/lib/helper.js +1 -1
- package/lib/helper.js.map +1 -1
- package/lib/markdown-2-html.js +7 -7
- package/lib/markdown-2-html.js.map +1 -1
- package/lib/methods/a.method.js +48 -48
- package/lib/methods/a.method.js.map +1 -1
- package/lib/methods/iframe.method.js +5 -5
- package/lib/methods/iframe.method.js.map +1 -1
- package/lib/methods/img.method.js +1 -1
- package/lib/methods/img.method.js.map +1 -1
- package/lib/methods/linkify.method.js +10 -10
- package/lib/methods/linkify.method.js.map +1 -1
- package/lib/methods/markdown-to-html.method.js +5 -5
- package/lib/methods/markdown-to-html.method.js.map +1 -1
- package/lib/methods/sanitize-html.method.js +1 -1
- package/lib/methods/sanitize-html.method.js.map +1 -1
- package/lib/methods/text.method.js +12 -12
- package/lib/methods/text.method.js.map +1 -1
- package/lib/methods/traverse.method.js +4 -4
- package/lib/methods/traverse.method.js.map +1 -1
- package/lib/post-body-summary.js +6 -5
- package/lib/post-body-summary.js.map +1 -1
- package/lib/proxify-image-src.js +12 -8
- 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 -0
- package/src/markdown-2-html.spec.ts +1 -1
- package/src/methods/markdown-to-html.method.ts +2 -2
- package/src/post-body-summary.ts +3 -1
- package/src/test/data/legacy/23.json +1 -1
- package/src/test/data/legacy/27.JSON +1 -1
package/package.json
CHANGED
|
@@ -39,3 +39,4 @@ export const BRAND_NEW_TUBE_REGEX = /^https:\/\/brandnewtube\.com\/embed\/[a-z0-
|
|
|
39
39
|
export const LOOM_REGEX = /^(https?:)?\/\/www.loom.com\/share\/(.*)/i
|
|
40
40
|
export const LOOM_EMBED_REGEX = /^(https?:)?\/\/www.loom.com\/embed\/(.*)/i
|
|
41
41
|
export const AUREAL_EMBED_REGEX = /^(https?:\/\/)?(www\.)?(?:aureal-embed)\.web\.app\/([0-9]+)/i
|
|
42
|
+
export const ENTITY_REGEX = /&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/ig;
|
|
@@ -142,7 +142,7 @@ describe('Markdown2Html', () => {
|
|
|
142
142
|
last_update: '2019-05-10T09:15:21',
|
|
143
143
|
body: '<iframe width="560" height="315" src="https://www.youtube.com/embed/I3f9ixg59no?foo=bar&baz=000" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
|
|
144
144
|
}
|
|
145
|
-
const expected = '<iframe src=\"https://www.youtube.com/embed/I3f9ixg59no\" allowfullscreen=\"allowfullscreen\"></iframe>'
|
|
145
|
+
const expected = '<iframe src=\"https://www.youtube.com/embed/I3f9ixg59no\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe>'
|
|
146
146
|
|
|
147
147
|
expect(markdown2Html(input)).toBe(expected)
|
|
148
148
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { traverse } from './traverse.method'
|
|
2
2
|
import { sanitizeHtml } from './sanitize-html.method'
|
|
3
|
-
import { DOMParser } from '../consts'
|
|
3
|
+
import { DOMParser, ENTITY_REGEX } from '../consts'
|
|
4
4
|
import xmldom from 'xmldom'
|
|
5
5
|
|
|
6
6
|
const lolight = require('lolight')
|
|
@@ -47,7 +47,7 @@ export function markdownToHTML(input: string, forApp: boolean, webp: boolean): s
|
|
|
47
47
|
let output = '';
|
|
48
48
|
|
|
49
49
|
//encrypt entities
|
|
50
|
-
const entities = input.match(
|
|
50
|
+
const entities = input.match(ENTITY_REGEX);
|
|
51
51
|
const encEntities:string[] = [];
|
|
52
52
|
|
|
53
53
|
try{
|
package/src/post-body-summary.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { makeEntryCacheKey } from './helper'
|
|
|
3
3
|
import { cacheGet, cacheSet } from './cache'
|
|
4
4
|
import { Entry } from './types'
|
|
5
5
|
import { cleanReply } from './methods'
|
|
6
|
+
import { ENTITY_REGEX } from './consts'
|
|
7
|
+
|
|
6
8
|
|
|
7
9
|
const { Remarkable } = require('remarkable')
|
|
8
10
|
const { linkify } = require('remarkable/linkify')
|
|
@@ -58,7 +60,7 @@ function postBodySummary(entryBody: string, length?: number, platform:'ios'|'and
|
|
|
58
60
|
]);
|
|
59
61
|
|
|
60
62
|
//encrypt entities
|
|
61
|
-
const entities = entryBody.match(
|
|
63
|
+
const entities = entryBody.match(ENTITY_REGEX);
|
|
62
64
|
const encEntities:string[] = [];
|
|
63
65
|
if(entities && platform !== 'web'){
|
|
64
66
|
entities.forEach((entity)=>{
|
|
@@ -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><IMG SRC=/ onerror=\"alert(String.fromCharCode(88,83,83))\"> <img src=\"https://images.ecency.com/p/35.png?format=match&mode=fit\"
|
|
4
|
+
"result": "<p><IMG SRC=/ onerror=\"alert(String.fromCharCode(88,83,83))\"> <img src=\"https://images.ecency.com/p/35.png?format=match&mode=fit\" /> <IMG SRC=javascript:alert('XSS')> <img /> <img /></p>"
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": 27,
|
|
3
3
|
"input": "<BR SIZE=\"&{alert('XSS')}\"> <LINK REL=\"stylesheet\" HREF=\"javascript:alert('XSS');\"> <STYLE>body{}</STYLE> <META HTTP-EQUIV=\"Link\" Content=\"<http://xss.rocks/xss.css>; REL=stylesheet\"> <IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME> foo <IFRAME SRC=# onmouseover=\"alert(document.cookie)\"></IFRAME> bar <FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET> baz ",
|
|
4
|
-
"result": "<p><br
|
|
4
|
+
"result": "<p><br /> foo bar baz\n</p>"
|
|
5
5
|
}
|