fix(html-view): scope the hidden-directory rule below the workspace root

The mint refused an HTML file whose absolute path had any dot segment, so
a workspace that itself lives under a hidden folder (~/.local/src/app)
could never render one of its own pages. For a file inside the workspace
the rule now covers the path below the workspace root, which is all the
page's tree can reach; outside the workspace it still covers the whole
path. A hidden directory below the workspace root is still refused.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-10-13 17:09:28 +02:00
1 parent 876dbca074
commit 69aa5724e7
3 files changed
+22 -3

No files matched your search

+15
View File
@@ -191,6 +191,21 @@ describe('html-view routes', () => {
expect((await open(join(root, '.hidden', 'r.html'))).statusCode).toBe(403);
});
it('renders a page in a workspace that itself lives under a hidden folder', async () => {
const hiddenWorkspace = join(root, '.local', 'src', 'app');
mkdirSync(join(hiddenWorkspace, 'report'), { recursive: true });
writeFileSync(join(hiddenWorkspace, 'report', 'index.html'), '<p>r</p>');
mkdirSync(join(hiddenWorkspace, '.cache'));
writeFileSync(join(hiddenWorkspace, '.cache', 'r.html'), '<p>r</p>');
(harness.ctx.sessions.get(sid) as { workingDir: string }).workingDir = hiddenWorkspace;
const res = await open(join(hiddenWorkspace, 'report', 'index.html'));
expect(res.statusCode).toBe(200);
expect((await harness.app.inject({ method: 'GET', url: JSON.parse(res.body).data.url })).statusCode).toBe(200);
// A hidden directory BELOW the workspace root is still refused.
expect((await open(join(hiddenWorkspace, '.cache', 'r.html'))).statusCode).toBe(403);
});
it('treats the filesystem root, home and the temp dir as too broad to serve', () => {
expect(isBroadHtmlViewRoot('/')).toBe(true);
expect(isBroadHtmlViewRoot(homedir())).toBe(true);