Page MenuHomeVyOS Platform

libvyosconfig parser does not support escaped quotes inside single-quoted strings
Closed, ResolvedPublicBUG


The parser from libvyosconfig used in vyos.configtree supports escaped quotes (single and double) in double-quoted strings, but trying to use them in a single-quoted string causes a parse error.

>>> c = vyos.configtree.ConfigTree(""" foo "fo\\'\\"o"  """)
>>> print(str(c))
foo "fo'\"o"

>>> c = vyos.configtree.ConfigTree(""" foo 'fo\\'\\"o'  """)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/vyos/", line 167, in __init__
    raise ValueError("Failed to parse config: {0}".format(msg))
ValueError: Failed to parse config: String is not terminated

This is really a lexer rather than a parser issue, it emits two tokens (STRING and IDENT) rather than one in that case.

While existing VyOS code always uses double quotes in config output, people with hand-edited configs can run into confusing errors.


Difficulty level
Unknown (require assessment)
Why the issue appeared?
Will be filled on close