Skip to content

Commit 5121ff1

Browse files
authored
Reject uploads on case insensitive filename matches. (#2114)
1 parent 2458c14 commit 5121ff1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

app/lib/frontend/backend.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,19 @@ Future<_ValidatedUpload> _parseAndValidateUpload(
860860

861861
final files = await listTarball(filename);
862862

863+
// Check whether the files can be extracted on case-preserving file systems
864+
// (e.g. on Windows). We can't allow two files with the same case-insensitive
865+
// name.
866+
final lowerCaseFiles = <String>{};
867+
for (String file in files) {
868+
final lower = file.toLowerCase();
869+
if (lowerCaseFiles.contains(lower)) {
870+
throw GenericProcessingException(
871+
'Filename collision on case-preserving file systems: $file.');
872+
}
873+
lowerCaseFiles.add(lower);
874+
}
875+
863876
// Searches in [files] for a file name [name] and compare in a
864877
// case-insensitive manner.
865878
//

app/lib/shared/utils.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ Future<T> withTempDirectory<T>(Future<T> func(Directory dir),
5151
}
5252

5353
Future<List<String>> listTarball(String path) async {
54-
// List files up-to 4 directory levels:
55-
final args = ['--exclude=*/*/*/*/*', '-tzf', path];
54+
final args = ['-tzf', path];
5655
final result = await Process.run('tar', args);
5756
if (result.exitCode != 0) {
5857
_logger.warning('The "tar $args" command failed:\n'

0 commit comments

Comments
 (0)