Skip to content

Commit cd64dd0

Browse files
committed
Include c9u in allowed file extensions when listing encrypted directories
1 parent 415cb76 commit cd64dd0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/main/java/org/cryptomator/cryptofs/dir/DirectoryStreamFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
import java.nio.file.Path;
1616
import java.util.HashMap;
1717
import java.util.Map;
18+
import java.util.Set;
1819

1920
@CryptoFileSystemScoped
2021
public class DirectoryStreamFactory {
2122

23+
private static final Set<String> FILE_EXTENSIONS = Set.of(Constants.CRYPTOMATOR_FILE_SUFFIX, Constants.DEFLATED_FILE_SUFFIX, Constants.INUSE_FILE_SUFFIX);
24+
2225
private final CryptoPathMapper cryptoPathMapper;
2326
private final DirectoryStreamComponent.Factory directoryStreamComponentFactory;
2427
private final Map<CryptoDirectoryStream, DirectoryStream<Path>> streams = new HashMap<>();
@@ -47,7 +50,7 @@ public synchronized CryptoDirectoryStream newDirectoryStream(CryptoPath cleartex
4750
boolean matchesEncryptedContentPattern(Path path) {
4851
var tmp = path.getFileName().toString();
4952
return tmp.length() >= Constants.MIN_CIPHER_NAME_LENGTH //
50-
&& (tmp.endsWith(Constants.CRYPTOMATOR_FILE_SUFFIX) || tmp.endsWith(Constants.DEFLATED_FILE_SUFFIX));
53+
&& FILE_EXTENSIONS.stream().anyMatch(tmp::endsWith);
5154
}
5255

5356
public synchronized void close() throws IOException {

src/test/java/org/cryptomator/cryptofs/dir/DirectoryStreamFactoryTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void testNewDirectoryStreamAfterClosedThrowsClosedFileSystemException() t
104104
});
105105
}
106106

107-
@DisplayName("CiphertextDirStream only contains files with names at least 26 chars long and ending with .c9r or .c9s")
107+
@DisplayName("CiphertextDirStream only contains files with names at least 26 chars long and ending with .c9r, .c9s or .c9u")
108108
@ParameterizedTest
109109
@MethodSource("provideFilterExamples")
110110
public void testCiphertextDirStreamFilter(String fileName, boolean expected) {
@@ -119,10 +119,12 @@ public void testCiphertextDirStreamFilter(String fileName, boolean expected) {
119119

120120
private static Stream<Arguments> provideFilterExamples() {
121121
return Stream.of( //
122+
Arguments.of("b".repeat(Constants.MIN_CIPHER_NAME_LENGTH - 5)+".c9u", false), //
122123
Arguments.of("b".repeat(Constants.MIN_CIPHER_NAME_LENGTH - 5)+".c9r", false), //
123124
Arguments.of("b".repeat(Constants.MIN_CIPHER_NAME_LENGTH - 5)+".c9s", false), //
124125
Arguments.of("a".repeat(Constants.MIN_CIPHER_NAME_LENGTH - 4)+".c9r", true), //
125-
Arguments.of("a".repeat(Constants.MIN_CIPHER_NAME_LENGTH - 4)+".c9s", true));
126+
Arguments.of("a".repeat(Constants.MIN_CIPHER_NAME_LENGTH - 4)+".c9s", true), //
127+
Arguments.of("a".repeat(Constants.MIN_CIPHER_NAME_LENGTH - 4)+".c9u", true));
126128
}
127129

128130
}

0 commit comments

Comments
 (0)