@thexjs/core 1.2.0 → 1.2.1

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 (2) hide show
  1. package/dist/index.js +9 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -446,8 +446,12 @@ function decodeLinkUrl(url) {
446
446
  return url;
447
447
  }
448
448
  }
449
+ function stripUrlControlChars(url) {
450
+ return url.replace(/[\t\n\r]/g, "");
451
+ }
449
452
  function isSafeLinkUrl(url) {
450
- const scheme = LINK_SCHEME_RE.exec(decodeLinkUrl(url.trim()))?.[1]?.toLowerCase();
453
+ const clean = stripUrlControlChars(url);
454
+ const scheme = LINK_SCHEME_RE.exec(decodeLinkUrl(clean.trim()))?.[1]?.toLowerCase();
451
455
  return scheme === void 0 || ALLOWED_LINK_SCHEMES.has(scheme);
452
456
  }
453
457
  function renderMarkdown(md) {
@@ -460,10 +464,10 @@ function renderMarkdown(md) {
460
464
  html = html.replace(/^### (.+)$/gm, "<h3>$1</h3>").replace(/^## (.+)$/gm, "<h2>$1</h2>").replace(/^# (.+)$/gm, "<h1>$1</h1>").replace(/`([^`]+)`/g, (_m, code) => {
461
465
  inlineCodes.push(code);
462
466
  return `__X_CODE_${inlineCodes.length - 1}__`;
463
- }).replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/\*([^*]+)\*/g, "<em>$1</em>").replace(
464
- /\[([^\]]+)\]\(([^)]+)\)/g,
465
- (_m, text, href) => isSafeLinkUrl(href) ? `<a href="${href}">${text}</a>` : text
466
- ).replace(/__X_CODE_(\d+)__/g, (_m, i) => `<code>${inlineCodes[Number.parseInt(i)]}</code>`);
467
+ }).replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/\*([^*]+)\*/g, "<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_m, text, href) => {
468
+ const clean = stripUrlControlChars(href);
469
+ return isSafeLinkUrl(clean) ? `<a href="${clean}">${text}</a>` : text;
470
+ }).replace(/__X_CODE_(\d+)__/g, (_m, i) => `<code>${inlineCodes[Number.parseInt(i)]}</code>`);
467
471
  html = html.replace(/__X_FENCE_(\d+)__/g, (_m, i) => fences[Number.parseInt(i)] ?? "");
468
472
  const blocks = html.split(/\n\n+/);
469
473
  html = blocks.map((b) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thexjs/core",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Full-stack React framework core (router, SSR/SSG renderer, islands, server functions) for the x framework, built on Bun.",
5
5
  "keywords": [
6
6
  "react",