Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(docs): prevent path traversal in doc slug lookup
Richie McIlroyd7989a3d166d
diff --git a/apps/web/utils/docs.ts b/apps/web/utils/docs.tsindex 94e4c1f5b..4eaa3e417 100644--- a/apps/web/utils/docs.ts+++ b/apps/web/utils/docs.ts@@ -83,7 +83,8 @@ export const getAllDocs = cache(function getAllDocs(): Doc[] {});export function getDocBySlug(slug: string): Doc | undefined {- const filePath = path.join(docsDir, `${slug}.mdx`);+ const filePath = path.resolve(docsDir, `${slug}.mdx`);+ if (!filePath.startsWith(docsDir)) return undefined;if (!fs.existsSync(filePath)) return undefined;const { metadata, content } = parseFrontmatter(fs.readFileSync(filePath, "utf-8"),