mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-09-28 15:08:47 +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 );
|
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();
|
||||||
|
Loading…
Reference in New Issue
Block a user