mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-09 18:03:08 +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:
@@ -739,6 +739,7 @@ public class FileSystem
|
|||||||
return sanitizePath( path, false );
|
return sanitizePath( path, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Pattern threeDotsPattern = Pattern.compile( "^\\.{3,}$" );
|
||||||
private static String sanitizePath( String path, boolean allowWildcards )
|
private static String sanitizePath( String path, boolean allowWildcards )
|
||||||
{
|
{
|
||||||
// Allow windowsy slashes
|
// Allow windowsy slashes
|
||||||
@@ -764,14 +765,15 @@ public class FileSystem
|
|||||||
Stack<String> outputParts = new Stack<>();
|
Stack<String> outputParts = new Stack<>();
|
||||||
for( String part : parts )
|
for( String part : parts )
|
||||||
{
|
{
|
||||||
if( part.length() == 0 || part.equals( "." ) )
|
if( part.length() == 0 || part.equals( "." ) || threeDotsPattern.matcher( part ).matches() )
|
||||||
{
|
{
|
||||||
// . is redundant
|
// . is redundant
|
||||||
|
// ... and more are treated as .
|
||||||
continue;
|
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() )
|
if( !outputParts.empty() )
|
||||||
{
|
{
|
||||||
String top = outputParts.peek();
|
String top = outputParts.peek();
|
||||||
|
|||||||
Reference in New Issue
Block a user