@gcunharodrigues/wrxn 0.18.1 → 0.18.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gcunharodrigues/wrxn",
3
- "version": "0.18.1",
3
+ "version": "0.18.3",
4
4
  "description": "WRXN Kernel — installable AI operating system. Two profiles (project | workspace), pull-based updates, managed/seeded/state file classes.",
5
5
  "bin": {
6
6
  "wrxn": "bin/wrxn.cjs"
@@ -43,7 +43,7 @@ const SIDECAR_EXTRA = [
43
43
  // OR bare (password=) — never a lone trailing quote, so a path ending in "passwd" used as a JSON key
44
44
  // (e.g. "../../etc/passwd": …) is NOT misread as an assignment (it would falsely refuse a sidecar write).
45
45
  /(?:["'](?:password|passwd|pwd)["']|(?:password|passwd|pwd))\s*[:=]\s*["']?[^\s"',;)&}{]+/i,
46
- /[a-z][a-z0-9+.\-]+:\/\/[^\s:/@]+:[^\s/@]+@\S+/i, // URI connection string with inline creds (scheme://user:pass@host)
46
+ /[a-z][a-z0-9+.\-]{1,19}:\/\/[^\s:/@]+:[^\s/@]+@\S+/i, // URI connection string with inline creds (scheme://user:pass@host); scheme bounded {1,19} so a long letter-run fails fast — no O(n²) backtrack (#66)
47
47
  /eyJ[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}/, // JWT (eyJ header; shorter min than the canonical JWT)
48
48
  ];
49
49
  const SECRET_PATTERNS = [...SECRET_PATTERNS_CANON, ...SIDECAR_EXTRA];
@@ -65,6 +65,27 @@ function pageBody(text) {
65
65
  return end < 0 ? '' : src.slice(end + 4);
66
66
  }
67
67
 
68
+ // Fenced code blocks (``` or ~~~) hold ILLUSTRATIVE text — a [[slug]] written there as example syntax is
69
+ // not a navigable wikilink, so it must not be checked for a dead target (#28). Strip whole fenced regions
70
+ // before the scan. Line-based + anchored (`^\s{0,3}` … `{3,}`) so it stays linear — no backtracking,
71
+ // mirroring wikilinkTargets' own ReDoS discipline. A fence closes only on the SAME marker char with no
72
+ // trailing info; an unclosed fence runs to end-of-body (CommonMark), so its content stays stripped.
73
+ function stripFencedCode(body) {
74
+ const kept = [];
75
+ let fence = ''; // '`' or '~' while inside a fenced block; '' when outside
76
+ for (const line of String(body || '').split('\n')) {
77
+ const m = /^\s{0,3}(`{3,}|~{3,})/.exec(line);
78
+ if (!fence) {
79
+ if (m) fence = m[1][0]; // open: drop the fence line, enter the block
80
+ else kept.push(line);
81
+ } else if (m && m[1][0] === fence && line.slice(m[0].length).trim() === '') {
82
+ fence = ''; // close: drop the fence line, leave the block
83
+ }
84
+ // a line inside a block (including the fences) is dropped
85
+ }
86
+ return kept.join('\n');
87
+ }
88
+
68
89
  // Wikilinks are written `[[slug]]` (Obsidian style), where slug equals a target page's `name:`. An
69
90
  // optional `|alias` or `#anchor` is stripped to the bare target slug. Returns the distinct slugs.
70
91
  // The inner class excludes BOTH `]` and `[`: a real `[[slug]]` target never contains `[`, and the
@@ -74,7 +95,12 @@ function wikilinkTargets(body) {
74
95
  const out = new Set();
75
96
  const re = /\[\[([^\]\[]+)\]\]/g;
76
97
  let m;
77
- while ((m = re.exec(String(body || '')))) {
98
+ // Strip fenced regions, THEN inline code spans (`…`): a [[slug]] in either is illustrative example syntax,
99
+ // not a navigable link, so it must not be checked for a dead target (#28). The inline pass uses disjoint
100
+ // adjacent classes (`+ / [^`\n] / `+) so it stays linear — no backtracking, per this file's ReDoS discipline;
101
+ // `\n` in the class keeps a span single-line so a stray backtick can't swallow real prose links below it.
102
+ const scannable = stripFencedCode(body).replace(/`+[^`\n]*`+/g, '');
103
+ while ((m = re.exec(scannable))) {
78
104
  const slug = m[1].split('|')[0].split('#')[0].trim();
79
105
  if (slug) out.add(slug);
80
106
  }