1- import { describe , it , expect , beforeEach , afterEach } from 'vitest' ;
1+ import { describe , it , expect , beforeEach , afterEach } from 'vitest' ;
22import * as path from 'path' ;
33import * as fs from 'fs/promises' ;
44import * as os from 'os' ;
@@ -40,7 +40,7 @@ async function getSymlinkSupport(): Promise<boolean> {
4040 if ( symlinkSupported === null ) {
4141 symlinkSupported = await checkSymlinkSupport ( ) ;
4242 if ( ! symlinkSupported ) {
43- console . log ( '\n鈿狅笍 Symlink tests will be skipped - symlink creation not supported in this environment' ) ;
43+ console . log ( '\n⚠️ Symlink tests will be skipped - symlink creation not supported in this environment' ) ;
4444 console . log ( ' On Windows, enable Developer Mode or run as Administrator to enable symlink tests' ) ;
4545 }
4646 }
@@ -194,10 +194,10 @@ describe('Path Validation', () => {
194194
195195 describe ( 'Unicode and special characters' , ( ) => {
196196 it ( 'handles unicode characters in paths' , ( ) => {
197- const allowed = [ '/home/user/caf茅 ' ] ;
197+ const allowed = [ '/home/user/café ' ] ;
198198
199- expect ( isPathWithinAllowedDirectories ( '/home/user/caf茅 ' , allowed ) ) . toBe ( true ) ;
200- expect ( isPathWithinAllowedDirectories ( '/home/user/caf茅 /file' , allowed ) ) . toBe ( true ) ;
199+ expect ( isPathWithinAllowedDirectories ( '/home/user/café ' , allowed ) ) . toBe ( true ) ;
200+ expect ( isPathWithinAllowedDirectories ( '/home/user/café /file' , allowed ) ) . toBe ( true ) ;
201201
202202 // Different unicode representation won't match (not normalized)
203203 const decomposed = '/home/user/cafe\u0301' ; // e + combining accent
@@ -679,7 +679,7 @@ describe('Path Validation', () => {
679679 it ( 'demonstrates symlink race condition allows writing outside allowed directories' , async ( ) => {
680680 const symlinkSupported = await getSymlinkSupport ( ) ;
681681 if ( ! symlinkSupported ) {
682- console . log ( ' 鈴笍 Skipping symlink race condition test - symlinks not supported' ) ;
682+ console . log ( ' ⏭️ Skipping symlink race condition test - symlinks not supported' ) ;
683683 return ;
684684 }
685685
@@ -701,7 +701,7 @@ describe('Path Validation', () => {
701701 it ( 'shows timing differences between validation approaches' , async ( ) => {
702702 const symlinkSupported = await getSymlinkSupport ( ) ;
703703 if ( ! symlinkSupported ) {
704- console . log ( ' 鈴笍 Skipping timing validation test - symlinks not supported' ) ;
704+ console . log ( ' ⏭️ Skipping timing validation test - symlinks not supported' ) ;
705705 return ;
706706 }
707707
@@ -722,7 +722,7 @@ describe('Path Validation', () => {
722722 it ( 'validates directory creation timing' , async ( ) => {
723723 const symlinkSupported = await getSymlinkSupport ( ) ;
724724 if ( ! symlinkSupported ) {
725- console . log ( ' 鈴笍 Skipping directory creation timing test - symlinks not supported' ) ;
725+ console . log ( ' ⏭️ Skipping directory creation timing test - symlinks not supported' ) ;
726726 return ;
727727 }
728728
@@ -742,7 +742,7 @@ describe('Path Validation', () => {
742742 it ( 'demonstrates exclusive file creation behavior' , async ( ) => {
743743 const symlinkSupported = await getSymlinkSupport ( ) ;
744744 if ( ! symlinkSupported ) {
745- console . log ( ' 鈴笍 Skipping exclusive file creation test - symlinks not supported' ) ;
745+ console . log ( ' ⏭️ Skipping exclusive file creation test - symlinks not supported' ) ;
746746 return ;
747747 }
748748
@@ -760,7 +760,7 @@ describe('Path Validation', () => {
760760 it ( 'should use resolved parent paths for non-existent files' , async ( ) => {
761761 const symlinkSupported = await getSymlinkSupport ( ) ;
762762 if ( ! symlinkSupported ) {
763- console . log ( ' 鈴笍 Skipping resolved parent paths test - symlinks not supported' ) ;
763+ console . log ( ' ⏭️ Skipping resolved parent paths test - symlinks not supported' ) ;
764764 return ;
765765 }
766766
@@ -784,7 +784,7 @@ describe('Path Validation', () => {
784784 it ( 'demonstrates parent directory symlink traversal' , async ( ) => {
785785 const symlinkSupported = await getSymlinkSupport ( ) ;
786786 if ( ! symlinkSupported ) {
787- console . log ( ' 鈴笍 Skipping parent directory symlink traversal test - symlinks not supported' ) ;
787+ console . log ( ' ⏭️ Skipping parent directory symlink traversal test - symlinks not supported' ) ;
788788 return ;
789789 }
790790
@@ -810,7 +810,7 @@ describe('Path Validation', () => {
810810 it ( 'should prevent race condition between validatePath and file operation' , async ( ) => {
811811 const symlinkSupported = await getSymlinkSupport ( ) ;
812812 if ( ! symlinkSupported ) {
813- console . log ( ' 鈴笍 Skipping race condition prevention test - symlinks not supported' ) ;
813+ console . log ( ' ⏭️ Skipping race condition prevention test - symlinks not supported' ) ;
814814 return ;
815815 }
816816
@@ -864,7 +864,7 @@ describe('Path Validation', () => {
864864 it ( 'should handle symlinks that point within allowed directories' , async ( ) => {
865865 const symlinkSupported = await getSymlinkSupport ( ) ;
866866 if ( ! symlinkSupported ) {
867- console . log ( ' 鈴笍 Skipping symlinks within allowed directories test - symlinks not supported' ) ;
867+ console . log ( ' ⏭️ Skipping symlinks within allowed directories test - symlinks not supported' ) ;
868868 return ;
869869 }
870870
@@ -896,7 +896,7 @@ describe('Path Validation', () => {
896896 it ( 'should prevent overwriting files through symlinks pointing outside allowed directories' , async ( ) => {
897897 const symlinkSupported = await getSymlinkSupport ( ) ;
898898 if ( ! symlinkSupported ) {
899- console . log ( ' 鈴笍 Skipping symlink overwrite prevention test - symlinks not supported' ) ;
899+ console . log ( ' ⏭️ Skipping symlink overwrite prevention test - symlinks not supported' ) ;
900900 return ;
901901 }
902902
@@ -932,7 +932,7 @@ describe('Path Validation', () => {
932932 it ( 'demonstrates race condition in read operations' , async ( ) => {
933933 const symlinkSupported = await getSymlinkSupport ( ) ;
934934 if ( ! symlinkSupported ) {
935- console . log ( ' 鈴笍 Skipping race condition in read operations test - symlinks not supported' ) ;
935+ console . log ( ' ⏭️ Skipping race condition in read operations test - symlinks not supported' ) ;
936936 return ;
937937 }
938938
@@ -964,7 +964,7 @@ describe('Path Validation', () => {
964964 it ( 'verifies rename does not follow symlinks' , async ( ) => {
965965 const symlinkSupported = await getSymlinkSupport ( ) ;
966966 if ( ! symlinkSupported ) {
967- console . log ( ' 鈴笍 Skipping rename symlink test - symlinks not supported' ) ;
967+ console . log ( ' ⏭️ Skipping rename symlink test - symlinks not supported' ) ;
968968 return ;
969969 }
970970
@@ -998,38 +998,3 @@ describe('Path Validation', () => {
998998 } ) ;
999999 } ) ;
10001000} ) ;
1001-
1002- describe ( 'Windows case-insensitivity (issue #3921, #447)' , ( ) => {
1003- // These assertions document the intended Windows behavior.
1004- // On non-Windows hosts we simulate the comparison semantics by
1005- // lower-casing both sides the same way the implementation does on win32.
1006- const ci = ( s : string ) => ( path . sep === '\\' ? s . toLowerCase ( ) : s ) ;
1007-
1008- const samePrefix = ( candidate : string , allowed : string ) : boolean => {
1009- const a = ci ( allowed ) ;
1010- const c = ci ( candidate ) ;
1011- return c === a || c . startsWith ( a + path . sep ) ;
1012- } ;
1013-
1014- it ( 'matches allowed dir regardless of drive-letter case' , ( ) => {
1015- const allowed = [ 'C:\\Users\\admin\\Desktop' ] ;
1016- expect ( isPathWithinAllowedDirectories ( 'c:\\users\\admin\\Desktop\\file.txt' , allowed ) ) . toBe ( true ) ;
1017- expect ( isPathWithinAllowedDirectories ( 'C:\\Users\\Admin\\Desktop' , allowed ) ) . toBe ( true ) ;
1018- } ) ;
1019-
1020- it ( 'matches allowed dir regardless of path case' , ( ) => {
1021- const allowed = [ 'C:\\Users\\admin\\desktop' ] ;
1022- expect ( isPathWithinAllowedDirectories ( 'C:\\Users\\Admin\\Desktop\\file.txt' , allowed ) )
1023- . toBe ( samePrefix ( 'C:\\Users\\Admin\\Desktop\\file.txt' , allowed [ 0 ] ) ) ;
1024- } ) ;
1025-
1026- it ( 'treats same directory with different case as equal' , ( ) => {
1027- const allowed = [ 'C:\\PROJECTS\\repo' ] ;
1028- expect ( isPathWithinAllowedDirectories ( 'c:\\projects\\repo' , allowed ) ) . toBe ( true ) ;
1029- } ) ;
1030-
1031- it ( 'UNC path is matched case-insensitively' , ( ) => {
1032- const allowed = [ '\\\\SERVER\\Share\\Folder' ] ;
1033- expect ( isPathWithinAllowedDirectories ( '\\\\server\\share\\folder\\f.txt' , allowed ) ) . toBe ( true ) ;
1034- } ) ;
1035- } ) ;
0 commit comments