1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-26 07:03:22 +00:00

Merge pull request #394 from Wojbie/bugfix/Filesystem-dots-#35

Modify logic behind ... and more in file path.
This commit is contained in:
Daniel Ratcliffe 2017-09-11 13:27:13 +01:00 committed by GitHub
commit 6c32d8a57e

View File

@ -739,6 +739,7 @@ private static String sanitizePath( String path )
return sanitizePath( path, false );
}
private static final Pattern threeDotsPattern = Pattern.compile( "^\\.{3,}$" );
private static String sanitizePath( String path, boolean allowWildcards )
{
// Allow windowsy slashes
@ -764,14 +765,15 @@ private static String sanitizePath( String path, boolean allowWildcards )
Stack<String> outputParts = new Stack<>();
for( String part : parts )
{
if( part.length() == 0 || part.equals( "." ) )
if( part.length() == 0 || part.equals( "." ) || threeDotsPattern.matcher( part ).matches() )
{
// . is redundant
// ... and more are treated as .
continue;
}
else if( part.equals( ".." ) || part.equals( "..." ) )
else if( part.equals( ".." ) )
{
// .. or ... can cancel out the last folder entered
// .. can cancel out the last folder entered
if( !outputParts.empty() )
{
String top = outputParts.peek();