check urls in assets downloading

This commit is contained in:
Bixilon 2021-01-04 22:00:31 +01:00
parent c515f495af
commit 713dfa9d2d
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -303,6 +303,7 @@ public class AssetsManager {
if (verifyAssetHash(hash)) {
return;
}
checkURL(url);
Log.verbose(String.format("Downloading %s -> %s", url, hash));
if (compressed) {
Util.downloadFileAsGz(url, getAssetDiskPath(hash));
@ -317,4 +318,10 @@ public class AssetsManager {
}
return StaticConfiguration.HOME_DIRECTORY + String.format("assets/objects/%s/%s.gz", hash.substring(0, 2), hash);
}
private static void checkURL(String url) {
if (!url.startsWith("http://") && !url.startsWith("https://")) {
throw new IllegalArgumentException("Not a valid url:" + url);
}
}
}