@@ -13,7 +13,14 @@ import {
1313import type { Page } from 'playwright-chromium'
1414import WebSocket from 'ws'
1515import testJSON from '../safe.json'
16- import { browser , isServe , page , viteServer , viteTestUrl } from '~utils'
16+ import {
17+ browser ,
18+ isServe ,
19+ isWindows ,
20+ page ,
21+ viteServer ,
22+ viteTestUrl ,
23+ } from '~utils'
1724
1825const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
1926
@@ -480,6 +487,23 @@ describe.runIf(isServe)('invalid request', () => {
480487 expect ( response ) . toContain ( 'HTTP/1.1 403 Forbidden' )
481488 } )
482489
490+ test ( 'should deny request to denied file when a request ends with \\' , async ( ) => {
491+ const response = await sendRawRequest ( viteTestUrl , '/src/.env\\' )
492+ expect ( response ) . toContain (
493+ isWindows ? 'HTTP/1.1 403 Forbidden' : 'HTTP/1.1 404 Not Found' ,
494+ )
495+ } )
496+
497+ test ( 'should deny request to denied file when a request ends with \\ with /@fs/' , async ( ) => {
498+ const response = await sendRawRequest (
499+ viteTestUrl ,
500+ path . posix . join ( '/@fs/' , root , 'root/src/.env' ) + '\\' ,
501+ )
502+ expect ( response ) . toContain (
503+ isWindows ? 'HTTP/1.1 403 Forbidden' : 'HTTP/1.1 404 Not Found' ,
504+ )
505+ } )
506+
483507 test ( 'should deny request with /@fs/ to denied file when a request has /.' , async ( ) => {
484508 const response = await sendRawRequest (
485509 viteTestUrl ,
0 commit comments