diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2022-04-02 16:21:55 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2022-04-02 16:21:55 +0200 |
commit | 2b3c3922531eef06d114191ab1685d663c83301e (patch) | |
tree | 0d9b1decd293952442945a987020773122676d1d | |
parent | a4bef5cc8746be403fdb0dbb952e80a2a6db6f33 (diff) |
Require HTTP(S) protocol
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java | 4 | ||||
-rw-r--r-- | vespajlib/src/test/java/ai/vespa/validation/NameTest.java | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java index b585f7e7e32..8072dab978f 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java @@ -16,6 +16,8 @@ import java.nio.ByteBuffer; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; import java.nio.file.Files; +import java.util.List; +import java.util.Locale; /** * @author baldersheim @@ -96,6 +98,8 @@ public class ApplicationFileManager implements AddFileInterface { file = new File(tmpDir, path.getRelative()); Files.createDirectories(file.getParentFile().toPath()); URL website = new URL(uri); + if ( ! List.of("http", "https").contains(website.getProtocol().toLowerCase(Locale.ROOT))) + throw new IllegalArgumentException("only HTTP(S) supported for URI type resources"); rbc = Channels.newChannel(website.openStream()); fos = new FileOutputStream(file); fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); diff --git a/vespajlib/src/test/java/ai/vespa/validation/NameTest.java b/vespajlib/src/test/java/ai/vespa/validation/NameTest.java index 0b50340870e..26a640b0ec0 100644 --- a/vespajlib/src/test/java/ai/vespa/validation/NameTest.java +++ b/vespajlib/src/test/java/ai/vespa/validation/NameTest.java @@ -1,12 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package ai.vespa.validation; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import java.nio.file.Path; - -import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; /** |