protected PathResource getFileResource ( final Path file , final String path , final Path symlinkBase , String normalizedFile ) throws IOException { if ( this . caseSensitive ) { if ( symlinkBase != null ) { String relative = symlinkBase . relativize ( file . normalize ( ) ) . toString ( ) ; String fileResolved = file . toRealPath ( ) . toString ( ) ; String symlinkBaseResolved = symlinkBase . toRealPath ( ) . toString ( ) ; if ( ! fileResolved . startsWith ( symlinkBaseResolved ) ) { log . tracef ( "Rejected path resource %s from path resource manager with base %s, as the case did not match actual case of %s" , path , base , normalizedFile ) ; return null ; } String compare = fileResolved . substring ( symlinkBaseResolved . length ( ) ) ; if ( compare . startsWith ( fileSystem . getSeparator ( ) ) ) { compare = compare . substring ( fileSystem . getSeparator ( ) . length ( ) ) ; } if ( relative . startsWith ( fileSystem . getSeparator ( ) ) ) { relative = relative . substring ( fileSystem . getSeparator ( ) . length ( ) ) ; } if ( relative . equals ( compare ) ) { log . tracef ( "Found path resource %s from path resource manager with base %s" , path , base ) ; return new PathResource ( file , this , path , eTagFunction . generate ( file ) ) ; } log . tracef ( "Rejected path resource %s from path resource manager with base %s, as the case did not match actual case of %s" , path , base , normalizedFile ) ; return null ; } else if ( isFileSameCase ( file , normalizedFile ) ) { log . tracef ( "Found path resource %s from path resource manager with base %s" , path , base ) ; return new PathResource ( file , this , path , eTagFunction . generate ( file ) ) ; } else { log . tracef ( "Rejected path resource %s from path resource manager with base %s, as the case did not match actual case of %s" , path , base , normalizedFile ) ; return null ; } } else { log . tracef ( "Found path resource %s from path resource manager with base %s" , path , base ) ; return new PathResource ( file , this , path , eTagFunction . generate ( file ) ) ; } }
Apply security check for case insensitive file systems .