mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-01 04:38:12 +00:00
Escaping VPCS name in regex #1067
This commit is contained in:
parent
40cc5d76b3
commit
7235a312ab
@ -171,7 +171,8 @@ class VPCSVM(BaseNode):
|
||||
if self.script_file:
|
||||
content = self.startup_script
|
||||
content = content.replace(self._name, new_name)
|
||||
content = re.sub(r"^set pcname .+$", "set pcname " + new_name, content, flags=re.MULTILINE)
|
||||
escaped_name = re.escape(new_name)
|
||||
content = re.sub(r"^set pcname .+$", "set pcname " + escaped_name, content, flags=re.MULTILINE)
|
||||
self.startup_script = content
|
||||
|
||||
super(VPCSVM, VPCSVM).name.__set__(self, new_name)
|
||||
|
@ -251,6 +251,12 @@ def test_update_startup_script_h(vm):
|
||||
assert f.read() == "set pcname pc1\n"
|
||||
|
||||
|
||||
def test_update_startup_script_with_escaping_characters_in_name(vm):
|
||||
vm.startup_script = "set pcname initial-name\n"
|
||||
vm.name = "test\\"
|
||||
assert vm.startup_script == "set pcname test\\\n"
|
||||
|
||||
|
||||
def test_get_startup_script(vm):
|
||||
content = "echo GNS3 VPCS\nip 192.168.1.2"
|
||||
vm.startup_script = content
|
||||
|
Loading…
Reference in New Issue
Block a user