libxml2 will properly escape < > and " in XML attribute content. If we use xmlEncodeEntitiesReentrant for attributes, this causes issues with UTF8 filenames (gvir_config_domain_disk_set_source for example): the filename UTF8 characters will be substituted with entities (é -> é), but when it uses this filename, libvirt will use it as is and will fail to find the file. I've tested that with this change gnome-boxes can open ISOs in directories with 'é' in their names, and in directories with '&foo;xx<' in their names. --- libvirt-gconfig/libvirt-gconfig-object.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c index 9a142c9..ee3584a 100644 --- a/libvirt-gconfig/libvirt-gconfig-object.c +++ b/libvirt-gconfig/libvirt-gconfig-object.c @@ -711,7 +711,6 @@ gvir_config_object_set_attribute(GVirConfigObject *object, ...) while (TRUE) { const char *name; const char *value; - xmlChar *encoded_value; name = va_arg(args, const char *); if (name == NULL) { @@ -723,9 +722,7 @@ gvir_config_object_set_attribute(GVirConfigObject *object, ...) g_warn_if_reached(); break; } - encoded_value = xmlEncodeEntitiesReentrant(doc, (xmlChar*)value); - xmlNewProp(object->priv->node, (xmlChar *)name, encoded_value); - xmlFree(encoded_value); + xmlNewProp(object->priv->node, (xmlChar *)name, (xmlChar *)value); } va_end(args); } @@ -780,17 +777,11 @@ gvir_config_object_set_attribute_with_type(GVirConfigObject *object, ...) str = g_strdup_printf("%d", val); break; } - case G_TYPE_STRING: { - xmlDocPtr doc; - xmlChar *enc_str; - + case G_TYPE_STRING: str = va_arg(args, char *); - g_object_get(G_OBJECT(object->priv->doc), "doc", &doc, NULL); - enc_str = xmlEncodeEntitiesReentrant(doc, (xmlChar*)str); - str = g_strdup((char *)enc_str); - xmlFree(enc_str); + xmlNewProp(object->priv->node, (xmlChar *)name, (xmlChar *)str); + str = NULL; break; - } case G_TYPE_BOOLEAN: { gboolean val; val = va_arg(args, gboolean); -- 1.7.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list