Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit bba30d0

Browse files
committed
Escape & chars in disk paths too
1 parent 5115d4c commit bba30d0

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

tests/misc-xml-escaping.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
2121
<console device='pty'/>
2222
<disk type='file' device='disk'>
23-
<source file='/ISO&apos;s'/>
23+
<source file='/ISO&amp;&apos;&amp;s'/>
2424
<target dev='hda'/>
2525
</disk>
2626
<disk type='block' device='cdrom'>

tests/xmlconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def testInstallFullyvirtDiskBlock(self):
182182

183183
def testXMLEscaping(self):
184184
g = self._get_basic_fullyvirt_guest()
185-
g.disks.append(virtinst.VirtualDisk("/ISO's", type=virtinst.VirtualDisk.TYPE_FILE, size=5))
185+
g.disks.append(virtinst.VirtualDisk("/ISO&'&s", type=virtinst.VirtualDisk.TYPE_FILE, size=5))
186186
self._compare(g, "misc-xml-escaping", True)
187187

188188

virtinst/Guest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ def get_xml_config(self, disknode):
180180
else:
181181
ret += " <driver name='%(name)s' type='%(type)s'/>\n" % { "name": self.driver_name, "type": self.driver_type }
182182
if self.path is not None:
183-
path = self.path.replace("'", "&apos;")
183+
path = self.path.replace("&", "&amp;")
184+
path = path.replace("'", "&apos;")
184185
ret += " <source %(typeattr)s='%(disk)s'/>\n" % { "typeattr": typeattr, "disk": path }
185186
if self.target is not None:
186187
disknode = self.target

0 commit comments

Comments
 (0)