osmo_vty: re.escape() the VTY prompt in connect()

The VTY prompt may contain regular expression metacharacters in it,
so the self.re_prompt will not match as expected.  One example is
the modem app in osmocom-bb.git using promot 'OsmocomBB(modem)'.

Change-Id: Ibada798a214be97409b55556724f558b67da7365
Related: osmo-python-tests.git I47b1f1c1765acb1b935dcbcc54bbb5eb539db4f0
This commit is contained in:
Vadim Yanitskiy 2023-04-12 22:19:47 +07:00 committed by Pau Espin Pedrol
parent eb0e007827
commit 38fd5677be
1 changed files with 1 additions and 1 deletions

View File

@ -178,7 +178,7 @@ class OsmoVty(log.Origin):
if not self.prompt:
raise VtyInterfaceExn('Could not find application name; needed to decode prompts.'
' Initial data was: %r' % data)
self.re_prompt = re.compile('^%s(?:\(([\w-]*)\))?([#>]) (.*)$' % self.prompt)
self.re_prompt = re.compile('^%s(?:\(([\w-]*)\))?([#>]) (.*)$' % re.escape(self.prompt))
def disconnect(self):
'''Disconnect.