From 6aa4a385a3b2eab9bd095b14d8a51848a3bbd868 Mon Sep 17 00:00:00 2001 From: Wojbie Date: Sun, 10 Sep 2017 17:51:29 +0200 Subject: [PATCH] Requested changes to logic behind ... in file path. --- .../java/dan200/computercraft/core/filesystem/FileSystem.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/dan200/computercraft/core/filesystem/FileSystem.java b/src/main/java/dan200/computercraft/core/filesystem/FileSystem.java index e630f7a83..f7584569b 100644 --- a/src/main/java/dan200/computercraft/core/filesystem/FileSystem.java +++ b/src/main/java/dan200/computercraft/core/filesystem/FileSystem.java @@ -740,6 +740,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 @@ -765,7 +766,7 @@ public class FileSystem Stack outputParts = new Stack(); for( String part : parts ) { - if( part.length() == 0 || part.equals( "." ) || part.matches( "^\\.{3,}$" ) ) + if( part.length() == 0 || part.equals( "." ) || threeDotsPattern.matcher( part ).matches() ) { // . is redundant // ... and more are treated as .