From aa88d5192338e2263516de791665f819a00b5c36 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 12 Jun 2019 11:29:07 -0500 Subject: 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. --- src/helpers/vyos-merge-config.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/helpers/vyos-merge-config.py') 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() -- cgit v1.2.3