From 08467a8107c3607066edd5045b9a11855cd73433 Mon Sep 17 00:00:00 2001 From: NullSablex <244216261+NullSablex@users.noreply.github.com> Date: Thu, 5 Feb 2026 20:38:44 -0300 Subject: [PATCH] =?UTF-8?q?fix(includes):=20corrige=20prote=C3=A7=C3=A3o?= =?UTF-8?q?=20contra=20loops=20sem=20limitar=20arquivos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Substitui maxFiles=500 por detecção de symlink loops via realpath. Aumenta maxDepth para 20. Todos os .inc são listados sem truncamento. --- package.json | 2 +- src/core/includes.ts | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 2d7c5f4..1591d88 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "pawnpro", "displayName": "PawnPro", "description": "%text.description%", - "version": "2.0.1", + "version": "2.0.2", "publisher": "NullSablex", "type": "module", "license": "SEE LICENSE IN LICENSE.md", diff --git a/src/core/includes.ts b/src/core/includes.ts index 75e971e..9aaae0a 100644 --- a/src/core/includes.ts +++ b/src/core/includes.ts @@ -155,10 +155,23 @@ function stripCommentsWhole(text: string): string { /* ─── Recursive file listing ────────────────────────────────────── */ -export async function listIncFilesRecursive(root: string, maxDepth = 10, maxFiles = 500): Promise { +export async function listIncFilesRecursive(root: string, maxDepth = 20): Promise { const out: string[] = []; + const visited = new Set(); // Prevent symlink loops + async function walk(dir: string, depth: number) { - if (depth > maxDepth || out.length >= maxFiles) return; + if (depth > maxDepth) return; + + // Resolve real path to detect symlink loops + let realDir: string; + try { + realDir = await fsp.realpath(dir); + } catch { + return; + } + if (visited.has(realDir)) return; + visited.add(realDir); + let entries; try { entries = await fsp.readdir(dir, { withFileTypes: true }); @@ -166,7 +179,6 @@ export async function listIncFilesRecursive(root: string, maxDepth = 10, maxFile return; } for (const e of entries) { - if (out.length >= maxFiles) break; const p = path.join(dir, e.name); if (e.isDirectory()) { if (e.name === 'node_modules' || e.name === '.git' || e.name === '.vscode' || e.name === '.pawnpro') continue;