summaryrefslogtreecommitdiff
path: root/src/helpers
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@sentrium.io>2019-06-12 11:29:07 -0500
committerJohn Estabrook <jestabro@sentrium.io>2019-06-12 11:29:07 -0500
commitaa88d5192338e2263516de791665f819a00b5c36 (patch)
tree76065334ee58f6c0fbccda177119e83612a44d6e /src/helpers
parent6f42122bc4b8ae8a287f0350eba4d8cd2f5f9649 (diff)
downloadvyos-1x-aa88d5192338e2263516de791665f819a00b5c36.tar.gz
vyos-1x-aa88d5192338e2263516de791665f819a00b5c36.zip
T1397: escape backslashes in output passed to configtree
The ouput of config.show_config (cli-shell-api showConfig) does not escape backslashes, whereas configtree expects escaped backslashes. Values containing unescaped backslashes consequently lead to a parsing error; cf. T1001.
Diffstat (limited to 'src/helpers')
-rwxr-xr-xsrc/helpers/vyos-merge-config.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/helpers/vyos-merge-config.py b/src/helpers/vyos-merge-config.py
index f0d5d1595..bb2919de2 100755
--- a/src/helpers/vyos-merge-config.py
+++ b/src/helpers/vyos-merge-config.py
@@ -64,6 +64,10 @@ merge_config_tree = ConfigTree(config_file)
effective_config = Config()
output_effective_config = effective_config.show_config()
+# showConfig (called by config.show_config() does not escape
+# backslashes, which configtree expects; cf. T1001.
+output_effective_config = output_effective_config.replace("\\", "\\\\")
+
effective_config_tree = ConfigTree(output_effective_config)
effective_cmds = effective_config_tree.to_commands()