Skip to content

Commit 113c56d

Browse files
committed
Even stricter sanity checks
1 parent b811689 commit 113c56d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: arduino-core/src/cc/arduino/contributions/DownloadableContributionsDownloader.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ public File download(DownloadableContribution contribution, Progress progress, f
6464
URL url = new URL(contribution.getUrl());
6565
// Filter out paths from file name
6666
String filename = new File(contribution.getArchiveFileName()).getName();
67-
Path outputFile = Paths.get(stagingFolder.getAbsolutePath(), filename);
67+
Path outputFile = Paths.get(stagingFolder.getAbsolutePath(), filename).normalize();
68+
if (outputFile.toFile().isDirectory()) {
69+
throw new Exception(format("Can't download {0}: invalid filename or exinsting directory", contribution.getArchiveFileName()));
70+
}
6871

6972
// Ensure the existence of staging folder
7073
Files.createDirectories(stagingFolder.toPath());

0 commit comments

Comments
 (0)