@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.
Files changed (37) hide show
  1. package/lib/catch-post-image.js +7 -7
  2. package/lib/catch-post-image.js.map +1 -1
  3. package/lib/consts/regexes.const.d.ts +1 -0
  4. package/lib/consts/regexes.const.js +2 -1
  5. package/lib/consts/regexes.const.js.map +1 -1
  6. package/lib/helper.js +1 -1
  7. package/lib/helper.js.map +1 -1
  8. package/lib/markdown-2-html.js +7 -7
  9. package/lib/markdown-2-html.js.map +1 -1
  10. package/lib/methods/a.method.js +48 -48
  11. package/lib/methods/a.method.js.map +1 -1
  12. package/lib/methods/iframe.method.js +5 -5
  13. package/lib/methods/iframe.method.js.map +1 -1
  14. package/lib/methods/img.method.js +1 -1
  15. package/lib/methods/img.method.js.map +1 -1
  16. package/lib/methods/linkify.method.js +10 -10
  17. package/lib/methods/linkify.method.js.map +1 -1
  18. package/lib/methods/markdown-to-html.method.js +5 -5
  19. package/lib/methods/markdown-to-html.method.js.map +1 -1
  20. package/lib/methods/sanitize-html.method.js +1 -1
  21. package/lib/methods/sanitize-html.method.js.map +1 -1
  22. package/lib/methods/text.method.js +12 -12
  23. package/lib/methods/text.method.js.map +1 -1
  24. package/lib/methods/traverse.method.js +4 -4
  25. package/lib/methods/traverse.method.js.map +1 -1
  26. package/lib/post-body-summary.js +6 -5
  27. package/lib/post-body-summary.js.map +1 -1
  28. package/lib/proxify-image-src.js +12 -8
  29. package/lib/proxify-image-src.js.map +1 -1
  30. package/lib/render-helper.js +1 -1
  31. package/package.json +1 -1
  32. package/src/consts/regexes.const.ts +1 -0
  33. package/src/markdown-2-html.spec.ts +1 -1
  34. package/src/methods/markdown-to-html.method.ts +2 -2
  35. package/src/post-body-summary.ts +3 -1
  36. package/src/test/data/legacy/23.json +1 -1
  37. package/src/test/data/legacy/27.JSON +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecency/render-helper",
3
- "version": "2.2.13",
3
+ "version": "2.2.14",
4
4
  "description": "Markdown+Html Render helper",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -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(/&(.*?);/g);
50
+ const entities = input.match(ENTITY_REGEX);
51
51
  const encEntities:string[] = [];
52
52
 
53
53
  try{
@@ -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(/&(.*?);/g);
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=\"&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041\"> <IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;> <IMG SRC=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29> <IMG SRC=\" &#14; javascript:alert('XSS');\">",
4
- "result": "<p>&lt;IMG SRC=/ onerror=\"alert(String.fromCharCode(88,83,83))\"&gt; <img src=\"https://images.ecency.com/p/35.png?format=match&amp;mode=fit\"> <img> <img> <img /></p>"
4
+ "result": "<p>&lt;IMG SRC=/ onerror=\"alert(String.fromCharCode(88,83,83))\"&gt; <img src=\"https://images.ecency.com/p/35.png?format=match&amp;mode=fit\" /> &lt;IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;&gt; <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> foo bar baz\n</p>"
4
+ "result": "<p><br /> foo bar baz\n</p>"
5
5
  }