mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-04-23 03:03:19 +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:
commit
6c32d8a57e
@ -739,6 +739,7 @@ public class FileSystem
|
||||
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 @@ public class FileSystem
|
||||
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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user