summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2026-08-25 13:09:16 -0500
committerJohn Estabrook <jestabro@vyos.io>2026-08-25 14:10:26 -0500
commit315e090194edb1883631ecf64d47d54bf8ec29fd (patch)
tree43b65820fe1e33bc1c0071df79074666e95630f5 /src
parent4719cedd5254ab091d890224e7d8f07e8b6304e7 (diff)
downloadvyos1x-config-315e090194edb1883631ecf64d47d54bf8ec29fd.tar.gz
vyos1x-config-315e090194edb1883631ecf64d47d54bf8ec29fd.zip
T9231: exclude spurious final tag value in subtree_from_partial
Diffstat (limited to 'src')
-rw-r--r--src/derived.ml31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/derived.ml b/src/derived.ml
index 6d82f98..b980801 100644
--- a/src/derived.ml
+++ b/src/derived.ml
@@ -21,6 +21,10 @@ let subtree_from_partial ?(descent=true) reftree ctree result path =
| [] -> false
| _ -> (Vytree.exists[@alert "-exn"]) ctree p
in
+ let spurious_value p =
+ Reference_tree.refpath_from_partial reftree p =
+ Reference_tree.refpath_from_partial reftree (Util.drop_last p)
+ in
let clone_node ?(descent=false) tree p =
if (Vytree.exists[@alert "-exn"]) tree p then
tree
@@ -48,19 +52,22 @@ let subtree_from_partial ?(descent=true) reftree ctree result path =
let p' = path_done @ [h] in
if check_ctree p' then aux (clone_node acc p') p' tl
else
- if (Config_tree.is_tag[@alert "-exn"]) ctree path_done then
- let children =
- Vytree.list_children ((Vytree.get[@alert "-exn"]) ctree path_done)
- in
- let func accum child =
- let path = path_done @ [child] @ [h] in
- if check_ctree path then
- aux (clone_node accum path) path tl
- else accum
- in
- List.fold_left func acc children
+ if (Config_tree.is_tag[@alert "-exn"]) ctree path_done &&
+ not (spurious_value p')
+ then
+ let children =
+ Vytree.list_children ((Vytree.get[@alert "-exn"]) ctree path_done)
+ in
+ let func accum child =
+ let path = path_done @ [child] @ [h] in
+ if check_ctree path then
+ aux (clone_node accum path) path tl
+ else accum
+ in
+ List.fold_left func acc children
else
- (* [h] is a tag_value not present in the config tree *)
+ (* [h] is a tag_value not present in the config tree
+ (non-tag path_done not, in fact, reachable here) *)
raise (Malformed_path (Util.string_of_list p'))
| _, [] ->
if descent then