Harden root screen containment

This commit is contained in:
Drew Ritter
2026-06-10 18:25:03 -07:00
parent ab8e65c356
commit 9e0ec508c6
2 changed files with 89 additions and 2 deletions

View File

@@ -186,8 +186,10 @@ function getNewestScreen() {
.filter(f => !f.startsWith('.') && f.endsWith('.html'))
.map(f => {
const fp = path.join(CONTENT_DIR, f);
if (!isRegularFileInsideContentDir(fp)) return null;
return { path: fp, mtime: fs.statSync(fp).mtime.getTime() };
})
.filter(Boolean)
.sort((a, b) => b.mtime - a.mtime);
return files.length > 0 ? files[0].path : null;
}