summaryrefslogtreecommitdiffstats
path: root/container-core/src/main/java/com/yahoo
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2023-03-30 15:43:42 +0200
committerjonmv <venstad@gmail.com>2023-03-30 15:43:42 +0200
commitaf2a2f12e6e220aca770ab2e342ca50240681d0d (patch)
tree88fcc037875e05d1108794067a46c140d095f0fd /container-core/src/main/java/com/yahoo
parentdb06ad61bdb8eac1d35800eea6b5cae56e392e1d (diff)
Forbid compound names whose children are illegal
Diffstat (limited to 'container-core/src/main/java/com/yahoo')
-rw-r--r--container-core/src/main/java/com/yahoo/processing/request/CompoundName.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/container-core/src/main/java/com/yahoo/processing/request/CompoundName.java b/container-core/src/main/java/com/yahoo/processing/request/CompoundName.java
index 51f7ae040eb..80a6ff1e4bf 100644
--- a/container-core/src/main/java/com/yahoo/processing/request/CompoundName.java
+++ b/container-core/src/main/java/com/yahoo/processing/request/CompoundName.java
@@ -94,16 +94,16 @@ public final class CompoundName {
int start = 0, end = i == 0 ? -1 : children[0].name.length();
for (int j = 0; j + i < children.length; j++) {
end += compounds[j + i].length() + 1;
+ if (end == start) throw new IllegalArgumentException("'" + name + "' is not a legal compound name. " +
+ "Consecutive, leading or trailing dots are not allowed.");
String subName = this.name.substring(start, end);
CompoundName cached = cache.get(subName);
- children[j] = start == end ? empty
- : cached != null
- ? cached
- : new CompoundName(subName,
- this.lowerCasedName.substring(start, end),
- Arrays.copyOfRange(compounds, j, j + i + 1),
- i == 0 ? empty : children[j + 1],
- i == 0 ? empty : children[j]);
+ children[j] = cached != null ? cached
+ : new CompoundName(subName,
+ this.lowerCasedName.substring(start, end),
+ Arrays.copyOfRange(compounds, j, j + i + 1),
+ i == 0 ? empty : children[j + 1],
+ i == 0 ? empty : children[j]);
if (useCache && cached == null) cache.put(subName, children[j]);
start += compounds[j].length() + 1;
}