This commit is contained in:
@@ -143,6 +143,13 @@ function isBlockedDocsSubpath(relFromDocs: string): boolean {
|
||||
});
|
||||
}
|
||||
|
||||
function sanitizeListedDescription(description: string): string {
|
||||
const referencesInternalDoc = BLOCKED_DOCS_SUBPATHS.some((blocked) =>
|
||||
description.includes(blocked.replace(/\/$/, '')),
|
||||
);
|
||||
return referencesInternalDoc ? '(description omitted: internal reference)' : description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a symbolic doc name to a concrete file path under an allow-listed root.
|
||||
* Returns null on invalid names, attempted traversal, or blocked internal docs.
|
||||
@@ -306,7 +313,7 @@ function extractMarkdownDescription(filePath: string): string {
|
||||
}
|
||||
if (line.startsWith('#')) continue;
|
||||
// Use this line as description
|
||||
return line.slice(0, 140);
|
||||
return sanitizeListedDescription(line.slice(0, 140));
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
@@ -326,7 +333,7 @@ function extractPieceDescription(filePath: string): string {
|
||||
.split('\n')
|
||||
.map((s) => s.trim())
|
||||
.find((s) => s.length > 0);
|
||||
return (first ?? '(no description)').slice(0, 140);
|
||||
return sanitizeListedDescription((first ?? '(no description)').slice(0, 140));
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
|
||||
Reference in New Issue
Block a user