xmlapi: Don't escape property values

libxml2 does that already.

Fixes #838
This commit is contained in:
Marius Vollmer 2025-02-13 14:11:02 +02:00
parent 5ddd3456a0
commit 31f6bad415
3 changed files with 78 additions and 2 deletions

View File

@ -0,0 +1,73 @@
<domain type="kvm">
<name>fedora</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<metadata>
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
<libosinfo:os id="http://fedoraproject.org/fedora/unknown"/>
</libosinfo:libosinfo>
</metadata>
<memory>65536</memory>
<currentMemory>65536</currentMemory>
<vcpu>2</vcpu>
<os>
<type arch="x86_64" machine="q35">hvm</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode="host-passthrough"/>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<pm>
<suspend-to-mem enabled="no"/>
<suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2" discard="unmap"/>
<source file="/var/lib/libvirt/images/fedora.qcow2"/>
<target dev="vda" bus="virtio"/>
</disk>
<controller type="usb" model="qemu-xhci" ports="15"/>
<controller type="pci" model="pcie-root"/>
<controller type="pci" model="pcie-root-port"/>
<controller type="pci" model="pcie-root-port"/>
<controller type="pci" model="pcie-root-port"/>
<controller type="pci" model="pcie-root-port"/>
<controller type="pci" model="pcie-root-port"/>
<controller type="pci" model="pcie-root-port"/>
<controller type="pci" model="pcie-root-port"/>
<controller type="pci" model="pcie-root-port"/>
<controller type="pci" model="pcie-root-port"/>
<controller type="pci" model="pcie-root-port"/>
<controller type="pci" model="pcie-root-port"/>
<controller type="pci" model="pcie-root-port"/>
<controller type="pci" model="pcie-root-port"/>
<controller type="pci" model="pcie-root-port"/>
<interface type="bridge">
<source bridge="testsuitebr0"/>
<mac address="00:11:22:33:44:55"/>
<model type="virtio"/>
</interface>
<console type="pty"/>
<channel type="unix">
<source mode="bind"/>
<target type="virtio" name="org.qemu.guest_agent.0"/>
</channel>
<input type="tablet" bus="usb"/>
<graphics type="vnc" port="-1" passwd="&amp;&quot;"/>
<video>
<model type="virtio"/>
</video>
<memballoon model="virtio"/>
<rng model="virtio">
<backend model="random">/dev/urandom</backend>
</rng>
</devices>
</domain>

View File

@ -975,7 +975,10 @@ c.add_compare(
"--disk /pool-dir/sharevol.img,perms=sh " # Colliding shareable storage
"", "storage-creation")
# Test encoding of funny password characters
c.add_compare(
"--graphics 'vnc,passwd=&\\\"' " # Ampersand and double-quote in a VNC password
"", "funny-passwords")
########################

View File

@ -348,7 +348,7 @@ class _Libxml2API(_XMLBase):
prop.unlinkNode()
prop.freeNode()
else:
node.setProp(propname, xmlutil.xml_escape(setval))
node.setProp(propname, setval)
def _node_new(self, xpathseg, parentnode):
newnode = libxml2.newNode(xpathseg.nodename)