1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-20 14:54:31 +01:00

Even stricter sanity checks

This commit is contained in:
Cristian Maglie 2020-01-21 12:32:51 +01:00 committed by Cristian Maglie
parent b811689e97
commit 113c56d657

View File

@ -64,7 +64,10 @@ public class DownloadableContributionsDownloader {
URL url = new URL(contribution.getUrl());
// Filter out paths from file name
String filename = new File(contribution.getArchiveFileName()).getName();
Path outputFile = Paths.get(stagingFolder.getAbsolutePath(), filename);
Path outputFile = Paths.get(stagingFolder.getAbsolutePath(), filename).normalize();
if (outputFile.toFile().isDirectory()) {
throw new Exception(format("Can't download {0}: invalid filename or exinsting directory", contribution.getArchiveFileName()));
}
// Ensure the existence of staging folder
Files.createDirectories(stagingFolder.toPath());