•  


fix: fs deny for case insensitive systems (#15653) · vitejs/vite@eeec23b · GitHub
Skip to content

Commit

Permalink
fix: fs deny for case insensitive systems ( #15653 )
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jan 19, 2024
1 parent c075115 commit eeec23b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions .
5 changes: 4 additions & 1 deletion packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,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 ,
} ) ,
_shortcutsOptions : undefined ,
}

Expand Down
8 changes: 7 additions & 1 deletion playground/fs-serve/__tests__/base/fs-serve-base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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 ( )
} )
} )

Expand Down
8 changes: 7 additions & 1 deletion playground/fs-serve/__tests__/fs-serve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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 ( )
} )
} )

Expand Down
16 changes: 15 additions & 1 deletion playground/fs-serve/root/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ <h2>Nested Entry</h2>

< h2 > Denied </ h2 >
< pre class =" unsafe-dotenv " > </ pre >
< pre class =" unsafe-dotEnV-casing " > </ pre >

< script type =" module " >
import '../../entry'
Expand Down Expand Up @@ -236,14 +237,27 @@ <h2>Denied</h2>
} )

// .env, denied by default
fetch ( joinUrlSegments ( base , joinUrlSegments ( '/@fs/' , ROOT ) + '/root/.env' ) )
fetch (
joinUrlSegments ( base , joinUrlSegments ( '/@fs/' , ROOT ) + '/root/src/.env' ) ,
)
. then ( ( r ) => {
text ( '.unsafe-dotenv' , r . status )
} )
. catch ( ( e ) => {
console . error ( e )
} )

// .env, for case insensitive file systems
fetch (
joinUrlSegments ( base , joinUrlSegments ( '/@fs/' , ROOT ) + '/root/src/.EnV' ) ,
)
. then ( ( r ) => {
text ( '.unsafe-dotEnV-casing' , r . status )
} )
. catch ( ( e ) => {
console . error ( e )
} )

function text ( sel , text ) {
document . querySelector ( sel ) . textContent = text
}
Expand Down

0 comments on commit eeec23b

Please sign in to comment.
- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본