diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2022-03-31 11:20:06 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2022-03-31 12:59:25 +0200 |
commit | 6478c2a16603f2f2163eb2116e58c363ab1cf37b (patch) | |
tree | 70420dae9deadd5282f1598bfd66b6f66490120a /config-lib/src/main/java/com/yahoo/config/FileNode.java | |
parent | f52ebfd454eb7b3c334e03b5c0ab47d4cb753e1f (diff) |
Improve error message for invalid config
Diffstat (limited to 'config-lib/src/main/java/com/yahoo/config/FileNode.java')
-rw-r--r-- | config-lib/src/main/java/com/yahoo/config/FileNode.java | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/config-lib/src/main/java/com/yahoo/config/FileNode.java b/config-lib/src/main/java/com/yahoo/config/FileNode.java index a7c1ebb1488..e6a4af6f439 100644 --- a/config-lib/src/main/java/com/yahoo/config/FileNode.java +++ b/config-lib/src/main/java/com/yahoo/config/FileNode.java @@ -1,6 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config; +import java.nio.file.Path; + /** * Represents a 'file' in a {@link ConfigInstance}, usually a filename. * @@ -14,6 +16,8 @@ public class FileNode extends LeafNode<FileReference> { public FileNode(String stringVal) { super(true); this.value = new FileReference(ReferenceNode.stripQuotes(stringVal)); + if (Path.of(value.value()).normalize().startsWith("..")) + throw new IllegalArgumentException("path may not start with '..', but got: " + value.value()); } public FileReference value() { |