[glib] gdbus: Use g_markup_collect_known_attributes() in GDBus introspection



commit 86329ba44fc7662c0bad37955f0ec980a24be495
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Aug 16 23:41:19 2012 -0400

    gdbus: Use g_markup_collect_known_attributes() in GDBus introspection
    
    In order to be able to cope with the introspection XML
    from the Telepathy specification, which uses attributes
    like tp:type and tp:name-for-bindings, we need to ignore
    unknown attributes when parsing.
    Closes: https://bugzilla.gnome.org/show_bug.cgi?id=665634

 gio/gdbusintrospection.c |  100 +++++++++++++++++++++------------------------
 1 files changed, 47 insertions(+), 53 deletions(-)
---
diff --git a/gio/gdbusintrospection.c b/gio/gdbusintrospection.c
index 30ad266..ca7490a 100644
--- a/gio/gdbusintrospection.c
+++ b/gio/gdbusintrospection.c
@@ -1276,14 +1276,12 @@ parser_start_element (GMarkupParseContext  *context,
           goto out;
         }
 
-      if (!g_markup_collect_attributes (element_name,
-                                        attribute_names,
-                                        attribute_values,
-                                        error,
-                                        G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "name", &name,
-                                        /* some hand-written introspection XML documents use this */
-                                        G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "xmlns:doc", NULL,
-                                        G_MARKUP_COLLECT_INVALID))
+      if (!g_markup_collect_known_attributes (element_name,
+                                              attribute_names,
+                                              attribute_values,
+                                              error,
+                                              G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "name", &name,
+                                              G_MARKUP_COLLECT_INVALID))
         goto out;
 
       g_dbus_node_info_set (data,
@@ -1315,14 +1313,12 @@ parser_start_element (GMarkupParseContext  *context,
           goto out;
         }
 
-      if (!g_markup_collect_attributes (element_name,
-                                        attribute_names,
-                                        attribute_values,
-                                        error,
-                                        G_MARKUP_COLLECT_STRING, "name", &name,
-                                        /* seen in the wild */
-                                        G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "version", NULL,
-                                        G_MARKUP_COLLECT_INVALID))
+      if (!g_markup_collect_known_attributes (element_name,
+                                              attribute_names,
+                                              attribute_values,
+                                              error,
+                                              G_MARKUP_COLLECT_STRING, "name", &name,
+                                              G_MARKUP_COLLECT_INVALID))
         goto out;
 
       g_dbus_interface_info_set (data,
@@ -1346,14 +1342,12 @@ parser_start_element (GMarkupParseContext  *context,
           goto out;
         }
 
-      if (!g_markup_collect_attributes (element_name,
-                                        attribute_names,
-                                        attribute_values,
-                                        error,
-                                        G_MARKUP_COLLECT_STRING, "name", &name,
-                                        /* seen in the wild */
-                                        G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "version", NULL,
-                                        G_MARKUP_COLLECT_INVALID))
+      if (!g_markup_collect_known_attributes (element_name,
+                                              attribute_names,
+                                              attribute_values,
+                                              error,
+                                              G_MARKUP_COLLECT_STRING, "name", &name,
+                                              G_MARKUP_COLLECT_INVALID))
         goto out;
 
       g_dbus_method_info_set (data,
@@ -1378,12 +1372,12 @@ parser_start_element (GMarkupParseContext  *context,
           goto out;
         }
 
-      if (!g_markup_collect_attributes (element_name,
-                                        attribute_names,
-                                        attribute_values,
-                                        error,
-                                        G_MARKUP_COLLECT_STRING, "name", &name,
-                                        G_MARKUP_COLLECT_INVALID))
+      if (!g_markup_collect_known_attributes (element_name,
+                                              attribute_names,
+                                              attribute_values,
+                                              error,
+                                              G_MARKUP_COLLECT_STRING, "name", &name,
+                                              G_MARKUP_COLLECT_INVALID))
         goto out;
 
       g_dbus_signal_info_set (data,
@@ -1409,14 +1403,14 @@ parser_start_element (GMarkupParseContext  *context,
           goto out;
         }
 
-      if (!g_markup_collect_attributes (element_name,
-                                        attribute_names,
-                                        attribute_values,
-                                        error,
-                                        G_MARKUP_COLLECT_STRING, "name", &name,
-                                        G_MARKUP_COLLECT_STRING, "type", &type,
-                                        G_MARKUP_COLLECT_STRING, "access", &access,
-                                        G_MARKUP_COLLECT_INVALID))
+      if (!g_markup_collect_known_attributes (element_name,
+                                              attribute_names,
+                                              attribute_values,
+                                              error,
+                                              G_MARKUP_COLLECT_STRING, "name", &name,
+                                              G_MARKUP_COLLECT_STRING, "type", &type,
+                                              G_MARKUP_COLLECT_STRING, "access", &access,
+                                              G_MARKUP_COLLECT_INVALID))
         goto out;
 
       if (strcmp (access, "read") == 0)
@@ -1460,14 +1454,14 @@ parser_start_element (GMarkupParseContext  *context,
           goto out;
         }
 
-      if (!g_markup_collect_attributes (element_name,
-                                        attribute_names,
-                                        attribute_values,
-                                        error,
-                                        G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "name", &name,
-                                        G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "direction", &direction,
-                                        G_MARKUP_COLLECT_STRING, "type", &type,
-                                        G_MARKUP_COLLECT_INVALID))
+      if (!g_markup_collect_known_attributes (element_name,
+                                              attribute_names,
+                                              attribute_values,
+                                              error,
+                                              G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "name", &name,
+                                              G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "direction", &direction,
+                                              G_MARKUP_COLLECT_STRING, "type", &type,
+                                              G_MARKUP_COLLECT_INVALID))
         goto out;
 
       if (strcmp (stack->next->data, "method") == 0)
@@ -1547,13 +1541,13 @@ parser_start_element (GMarkupParseContext  *context,
           goto out;
         }
 
-      if (!g_markup_collect_attributes (element_name,
-                                        attribute_names,
-                                        attribute_values,
-                                        error,
-                                        G_MARKUP_COLLECT_STRING, "name", &name,
-                                        G_MARKUP_COLLECT_STRING, "value", &value,
-                                        G_MARKUP_COLLECT_INVALID))
+      if (!g_markup_collect_known_attributes (element_name,
+                                              attribute_names,
+                                              attribute_values,
+                                              error,
+                                              G_MARKUP_COLLECT_STRING, "name", &name,
+                                              G_MARKUP_COLLECT_STRING, "value", &value,
+                                              G_MARKUP_COLLECT_INVALID))
         goto out;
 
       g_dbus_annotation_info_set (data,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]