comparison libpurple/protocols/bonjour/parser.c @ 26262:b03430dae08e

Add xmlnode_set_attrib_full that enables you to set an attribute with both a prefix and a namespace. Also, change xmlnode_remove_attribute to remove all existing attributes that match the name. Otherwise, it would just take out the first one, and may not do what you want. Change Bonjour and XMPP to use the new function. References #7681. Fixes #8318.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 13 Mar 2009 04:29:11 +0000
parents 1c87e81c44fa
children 17379effc417
comparison
equal deleted inserted replaced
26261:413b445a6018 26262:b03430dae08e
89 else 89 else
90 node = xmlnode_new((const char*) element_name); 90 node = xmlnode_new((const char*) element_name);
91 xmlnode_set_namespace(node, (const char*) namespace); 91 xmlnode_set_namespace(node, (const char*) namespace);
92 92
93 for(i=0; i < nb_attributes * 5; i+=5) { 93 for(i=0; i < nb_attributes * 5; i+=5) {
94 const char *name = (const char *)attributes[i];
95 const char *prefix = (const char *)attributes[i+1];
96 const char *attrib_ns = (const char *)attributes[i+2];
94 char *txt; 97 char *txt;
95 int attrib_len = attributes[i+4] - attributes[i+3]; 98 int attrib_len = attributes[i+4] - attributes[i+3];
96 char *attrib = g_malloc(attrib_len + 1); 99 char *attrib = g_malloc(attrib_len + 1);
97 char *attrib_ns = NULL;
98
99 if (attributes[i+2]) {
100 attrib_ns = g_strdup((char*)attributes[i+2]);
101 }
102 100
103 memcpy(attrib, attributes[i+3], attrib_len); 101 memcpy(attrib, attributes[i+3], attrib_len);
104 attrib[attrib_len] = '\0'; 102 attrib[attrib_len] = '\0';
105 103
106 txt = attrib; 104 txt = attrib;
107 attrib = purple_unescape_html(txt); 105 attrib = purple_unescape_html(txt);
108 g_free(txt); 106 g_free(txt);
109 xmlnode_set_attrib_with_namespace(node, (const char*) attributes[i], attrib_ns, attrib); 107 xmlnode_set_attrib_full(node, name, attrib_ns, prefix, attrib);
110 g_free(attrib); 108 g_free(attrib);
111 g_free(attrib_ns);
112 } 109 }
113 110
114 bconv->current = node; 111 bconv->current = node;
115 } 112 }
116 } 113 }