@ecency/render-helper 2.5.17 → 2.5.19

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/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Ecency render helper
2
2
 
3
+ Built and maintained by [Ecency](https://ecency.com), an open-source social platform on the Hive blockchain.
4
+
3
5
  ## Project Overview
4
6
 
5
7
  `@ecency/render-helper` is a TypeScript library for rendering and sanitizing markdown+HTML content for the Ecency social platform (built on Hive blockchain). It provides security-focused content rendering with XSS protection, image proxification, and embedded media filtering.
@@ -2088,10 +2088,11 @@ var BACKTICK_FENCE_RE = /```[\s\S]*?```/g;
2088
2088
  var TILDE_FENCE_RE = /~~~[\s\S]*?~~~/g;
2089
2089
  var INLINE_CODE_RE = /`[^`\n]*`/g;
2090
2090
  var INDENTED_CODE_RE = /^(?: {4}|\t).+$/gm;
2091
- var MD_IMAGE_RE = /!\[[^\]]*\]\(\s*([^)\s]+)(?:\s+["'][^"']*["'])?\s*\)/;
2091
+ var MD_IMAGE_RE = /!\[[^[\]]*\]\(\s*([^)\s]{1,2048})(?:\s+["'][^"']*["'])?\s*\)/;
2092
+ var MD_IMAGE_PRESENT_RE = /!\[[^[\]]*\]\(\s*[^\s)]/;
2092
2093
  var HTML_IMAGE_RE = /<img\b[^>]*?\bsrc\s*=\s*["']([^"']+)["']/i;
2093
2094
  var BARE_IMAGE_RE = /(^|\s)(https?:\/\/[^\s<>"'()[\]]+\.(?:tiff?|jpe?g|gif|png|svg|ico|heic|webp|arw)(?:[?#][^\s<>"'()[\]]*)?)/im;
2094
- var MD_LINK_RE = /\[([^\]]*)\]\(\s*([^)\s]+)(?:\s+["'][^"']*["'])?\s*\)/g;
2095
+ var MD_LINK_RE = /\[([^[\]]*)\]\(\s*([^)\s[]+)(?:\s+["'][^"']*["'])?\s*\)/g;
2095
2096
  var IMG_HREF_RE = /https?:\/\/.*\.(?:tiff?|jpe?g|gif|png|svg|ico|heic|webp|arw)/i;
2096
2097
  var SAFE_URL_RE = /^https?:\/\//i;
2097
2098
  function findFirstImageUrl(body, includeBareUrls = false) {
@@ -2105,6 +2106,10 @@ function findFirstImageUrl(body, includeBareUrls = false) {
2105
2106
  return null;
2106
2107
  }
2107
2108
  }
2109
+ const priorRegion = mdMatch ? cleaned.slice(0, mdMatch.index ?? 0) : cleaned;
2110
+ if (MD_IMAGE_PRESENT_RE.test(priorRegion)) {
2111
+ return null;
2112
+ }
2108
2113
  const candidates = [];
2109
2114
  if (mdMatch) candidates.push({ url: mdMatch[1], pos: mdMatch.index ?? 0 });
2110
2115
  if (htmlMatch && htmlMatch[1] && SAFE_URL_RE.test(htmlMatch[1])) {