From 99080ca3e6c2dcdc3c2d67bb2d143c59e0a329f2 Mon Sep 17 00:00:00 2001 From: patak Date: Fri, 19 Jan 2024 14:31:10 +0100 Subject: [PATCH] fix: port #15653 to v3 (#15655) --- packages/vite/src/node/server/index.ts | 5 ++++- playground/fs-serve/__tests__/fs-serve.spec.ts | 8 +++++++- playground/fs-serve/root/src/index.html | 12 +++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index 7ea1d846183bb5..a5429b9dc32ec7 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -452,7 +452,10 @@ export async function createServer( _importGlobMap: new Map(), _forceOptimizeOnRestart: false, _pendingRequests: new Map(), - _fsDenyGlob: picomatch(config.server.fs.deny, { matchBase: true }) + _fsDenyGlob: picomatch(config.server.fs.deny, { + matchBase: true, + nocase: true + }) } server.transformIndexHtml = createDevHtmlTransformFn(server) diff --git a/playground/fs-serve/__tests__/fs-serve.spec.ts b/playground/fs-serve/__tests__/fs-serve.spec.ts index 90d35d21b04773..c22e5def30fe7d 100644 --- a/playground/fs-serve/__tests__/fs-serve.spec.ts +++ b/playground/fs-serve/__tests__/fs-serve.spec.ts @@ -95,7 +95,13 @@ describe.runIf(isServe)('main', () => { }) test('denied', async () => { - expect(await page.textContent('.unsafe-dotenv')).toBe('404') + expect(await page.textContent('.unsafe-dotenv')).toBe('403') + }) + + test('denied EnV casing', async () => { + // It is 403 in case insensitive system, 404 in others + const code = await page.textContent('.unsafe-dotEnV-casing') + expect(code === '403' || code === '404').toBeTruthy() }) }) diff --git a/playground/fs-serve/root/src/index.html b/playground/fs-serve/root/src/index.html index 95b31e73d72ea6..565961d34cd889 100644 --- a/playground/fs-serve/root/src/index.html +++ b/playground/fs-serve/root/src/index.html @@ -45,6 +45,7 @@

Nested Entry

Denied


+