File tree 3 files changed +22
-3
lines changed
packages/vite/src/node/server
3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -452,7 +452,10 @@ export async function createServer(
452
452
_importGlobMap : new Map ( ) ,
453
453
_forceOptimizeOnRestart : false ,
454
454
_pendingRequests : new Map ( ) ,
455
- _fsDenyGlob : picomatch ( config . server . fs . deny , { matchBase : true } )
455
+ _fsDenyGlob : picomatch ( config . server . fs . deny , {
456
+ matchBase : true ,
457
+ nocase : true
458
+ } )
456
459
}
457
460
458
461
server . transformIndexHtml = createDevHtmlTransformFn ( server )
Original file line number Diff line number Diff line change @@ -95,7 +95,13 @@ describe.runIf(isServe)('main', () => {
95
95
} )
96
96
97
97
test ( 'denied' , async ( ) => {
98
- expect ( await page . textContent ( '.unsafe-dotenv' ) ) . toBe ( '404' )
98
+ expect ( await page . textContent ( '.unsafe-dotenv' ) ) . toBe ( '403' )
99
+ } )
100
+
101
+ test ( 'denied EnV casing' , async ( ) => {
102
+ // It is 403 in case insensitive system, 404 in others
103
+ const code = await page . textContent ( '.unsafe-dotEnV-casing' )
104
+ expect ( code === '403' || code === '404' ) . toBeTruthy ( )
99
105
} )
100
106
} )
101
107
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ <h2>Nested Entry</h2>
45
45
46
46
< h2 > Denied</ h2 >
47
47
< pre class ="unsafe-dotenv "> </ pre >
48
+ < pre class ="unsafe-dotEnV-casing "> </ pre >
48
49
49
50
< script type ="module ">
50
51
import '../../entry'
@@ -202,14 +203,23 @@ <h2>Denied</h2>
202
203
} )
203
204
204
205
// .env, denied by default
205
- fetch ( '/@fs/' + ROOT + '/root/.env' )
206
+ fetch ( '/@fs/' + ROOT + '/root/src/ .env' )
206
207
. then ( ( r ) => {
207
208
text ( '.unsafe-dotenv' , r . status )
208
209
} )
209
210
. catch ( ( e ) => {
210
211
console . error ( e )
211
212
} )
212
213
214
+ // .env, for case insensitive file systems
215
+ fetch ( '/@fs/' + ROOT + '/root/src/.EnV' )
216
+ . then ( ( r ) => {
217
+ text ( '.unsafe-dotEnV-casing' , r . status )
218
+ } )
219
+ . catch ( ( e ) => {
220
+ console . error ( e )
221
+ } )
222
+
213
223
function text ( sel , text ) {
214
224
document . querySelector ( sel ) . textContent = text
215
225
}
You can’t perform that action at this time.
0 commit comments