<value>foo</value> should mean the same thing as
authorDan Winship <danw@src.gnome.org>
Mon, 20 Nov 2006 21:34:53 +0000 (21:34 +0000)
committerDan Winship <danw@src.gnome.org>
Mon, 20 Nov 2006 21:34:53 +0000 (21:34 +0000)
* libsoup/soup-xmlrpc-response.c (soup_xmlrpc_value_get_type)
(soup_xmlrpc_value_get_string): <value>foo</value> should mean the
same thing as <value><string>foo</string></value>. Pointed out by
Todd Kulesza. #364490

ChangeLog
libsoup/soup-xmlrpc-response.c

index 7a0d0ee..a22b1f3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-11-20  Dan Winship  <danw@novell.com>
+
+       * libsoup/soup-xmlrpc-response.c (soup_xmlrpc_value_get_type)
+       (soup_xmlrpc_value_get_string): <value>foo</value> should mean the
+       same thing as <value><string>foo</string></value>. Pointed out by
+       Todd Kulesza. #364490
+
 2006-11-06  Dan Winship  <danw@novell.com>
 
        * configure.in: Bump version to 2.2.97. Bump AGE and CURRENT for
index 1154c2b..84dabf0 100644 (file)
@@ -203,6 +203,11 @@ soup_xmlrpc_value_get_type (SoupXmlrpcValue *value)
        if (!xml)
                return SOUP_XMLRPC_VALUE_TYPE_BAD;
 
+       if (xml->type == XML_TEXT_NODE)
+               return SOUP_XMLRPC_VALUE_TYPE_STRING;
+       else if (xml->type != XML_ELEMENT_NODE)
+               return SOUP_XMLRPC_VALUE_TYPE_BAD;
+       
        if (strcmp ((const char *)xml->name, "i4") == 0 || strcmp ((const char *)xml->name, "int") == 0)
                return SOUP_XMLRPC_VALUE_TYPE_INT;
        else if (strcmp ((const char *)xml->name, "boolean") == 0)
@@ -310,9 +315,14 @@ soup_xmlrpc_value_get_string (SoupXmlrpcValue *value, char **str)
        if (strcmp ((const char *)xml->name, "value"))
                return FALSE;
        xml = exactly_one_child (xml);
-       if (!xml || strcmp ((const char *)xml->name, "string"))
+       if (!xml)
                return FALSE;
-
+       if (xml->type == XML_ELEMENT_NODE) {
+               if (strcmp ((char *)xml->name, "string"))
+                       return FALSE;
+       } else if (xml->type != XML_TEXT_NODE)
+               return FALSE;
+       
        content = xmlNodeGetContent (xml);
        *str = content ? g_strdup ((char *)content) : g_strdup ("");
        xmlFree (content);