Handling of special characters is a chronic headache for VyOS developers and users alike. Quotes is the most common issue, but there are others.
The first inconsistency is that you cannot enter a value with quotes from the CLI, but you can load a config with such values. Then things get funny.
The life of any character inside a node value includes these stages:
- First it's read and interpreted by the lexer
- Then it's passed to config scripts
- Then it's inserted into the target application config
The current behaviour as of 1.2 is: after parsing, quotes are backslash-escaped. When it's passed to the config script, the backslash itself is escaped, while the quote is not. As confusing as it sounds:
>>> import vyos.config >>> c = vyos.config.Config() >>> c.return_value("system login user dmbaturin full-name") 'Daniil\\"Baturin' >>> print(c.return_value("system login user dmbaturin full-name")) Daniil\"Baturin
One can regard quotes inside values as pathological, but there are valid reasons to have them:
- Inside pre-shared keys (arguing with the other side over their PSK can be a futile exercise)
- In script arguments
- In raw options passed to the target application (openvpn-option etc.)
After T1801, the libvyosconfig-based implementation behaves like 1.2. However, it's not clear if that's what we really want.
Instead, we may want to redo it to always pass raw strings to config scripts, and adjust the scripts to do their own escaping when required.