Mercurial > pidgin
comparison libpurple/xmlnode.c @ 30956:61d160a4689f
Move the call to flap_connection_schedule_destroy from oscar_chat_kill
to oscar_chat_leave. This avoids having flap_connection_schedule_destroy
called from purple_connerr, which itself is called by flap_connection_destroy_cb
I'm hoping this change fixes #5927, the oscar crash when a flap connection
is disconnected.
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Mon, 22 Nov 2010 10:45:46 +0000 |
| parents | 77cd42f08ba1 |
| children | 3cf95447b26c |
comparison
equal
deleted
inserted
replaced
| 30955:6f9a43a2b716 | 30956:61d160a4689f |
|---|---|
| 44 # define NEWLINE_S "\r\n" | 44 # define NEWLINE_S "\r\n" |
| 45 #else | 45 #else |
| 46 # define NEWLINE_S "\n" | 46 # define NEWLINE_S "\n" |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 #ifdef CHECKING_XML_STRINGS_FOR_VALID_CHARACTERS | |
| 50 /* | |
| 51 * The purpose of this function is to prevent us from creating XML documents | |
| 52 * that contain characters that are not allowed in XML 1.0. However, this | |
| 53 * change is unfortunately REALLY slow. | |
| 54 */ | |
| 55 static gboolean is_valid_xml10(const char *str) | |
| 56 { | |
| 57 gunichar ch; | |
| 58 | |
| 59 for (ch = g_utf8_get_char(str); str[0] != '\0'; str = g_utf8_next_char(str)) | |
| 60 { | |
| 61 /* | |
| 62 * Valid characters in XML 1.0 are: #x9 #xA #xD | |
| 63 * [#x20-#xD7FF] [#xE000-#xFFFD] [#x10000-#x10FFFF] | |
| 64 */ | |
| 65 if (ch < 0x09 || (ch > 0x0a && ch < 0x0d) || (ch > 0x0d && ch < 0x20)) | |
| 66 return FALSE; | |
| 67 } | |
| 68 | |
| 69 return TRUE; | |
| 70 } | |
| 71 #endif /* CHECKING_XML_STRINGS_FOR_VALID_CHARACTERS */ | |
| 72 | |
| 49 static xmlnode* | 73 static xmlnode* |
| 50 new_node(const char *name, XMLNodeType type) | 74 new_node(const char *name, XMLNodeType type) |
| 51 { | 75 { |
| 52 xmlnode *node = g_new0(xmlnode, 1); | 76 xmlnode *node = g_new0(xmlnode, 1); |
| 53 | 77 |
| 106 gsize real_size; | 130 gsize real_size; |
| 107 | 131 |
| 108 g_return_if_fail(node != NULL); | 132 g_return_if_fail(node != NULL); |
| 109 g_return_if_fail(data != NULL); | 133 g_return_if_fail(data != NULL); |
| 110 g_return_if_fail(size != 0); | 134 g_return_if_fail(size != 0); |
| 135 | |
| 136 #ifdef CHECKING_XML_STRINGS_FOR_VALID_CHARACTERS | |
| 137 g_return_if_fail(is_valid_xml10(data)); | |
| 138 #endif /* CHECKING_XML_STRINGS_FOR_VALID_CHARACTERS */ | |
| 111 | 139 |
| 112 real_size = size == -1 ? strlen(data) : size; | 140 real_size = size == -1 ? strlen(data) : size; |
| 113 | 141 |
| 114 child = new_node(NULL, XMLNODE_TYPE_DATA); | 142 child = new_node(NULL, XMLNODE_TYPE_DATA); |
| 115 | 143 |
| 184 } | 212 } |
| 185 | 213 |
| 186 void | 214 void |
| 187 xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value) | 215 xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value) |
| 188 { | 216 { |
| 217 #ifdef CHECKING_XML_STRINGS_FOR_VALID_CHARACTERS | |
| 218 g_return_if_fail(is_valid_xml10(attr)); | |
| 219 g_return_if_fail(is_valid_xml10(value)); | |
| 220 #endif /* CHECKING_XML_STRINGS_FOR_VALID_CHARACTERS */ | |
| 221 | |
| 189 xmlnode_remove_attrib(node, attr); | 222 xmlnode_remove_attrib(node, attr); |
| 190 xmlnode_set_attrib_full(node, attr, NULL, NULL, value); | 223 xmlnode_set_attrib_full(node, attr, NULL, NULL, value); |
| 191 } | 224 } |
| 192 | 225 |
| 193 void | 226 void |
| 208 xmlnode *attrib_node; | 241 xmlnode *attrib_node; |
| 209 | 242 |
| 210 g_return_if_fail(node != NULL); | 243 g_return_if_fail(node != NULL); |
| 211 g_return_if_fail(attr != NULL); | 244 g_return_if_fail(attr != NULL); |
| 212 g_return_if_fail(value != NULL); | 245 g_return_if_fail(value != NULL); |
| 246 #ifdef CHECKING_XML_STRINGS_FOR_VALID_CHARACTERS | |
| 247 g_return_if_fail(is_valid_xml10(attr)); | |
| 248 if (xmlns != NULL) | |
| 249 g_return_if_fail(is_valid_xml10(xmlns)); | |
| 250 if (prefix != NULL) | |
| 251 g_return_if_fail(is_valid_xml10(prefix)); | |
| 252 g_return_if_fail(is_valid_xml10(value)); | |
| 253 #endif /* CHECKING_XML_STRINGS_FOR_VALID_CHARACTERS */ | |
| 213 | 254 |
| 214 xmlnode_remove_attrib_with_namespace(node, attr, xmlns); | 255 xmlnode_remove_attrib_with_namespace(node, attr, xmlns); |
| 215 attrib_node = new_node(attr, XMLNODE_TYPE_ATTRIB); | 256 attrib_node = new_node(attr, XMLNODE_TYPE_ATTRIB); |
| 216 | 257 |
| 217 attrib_node->data = g_strdup(value); | 258 attrib_node->data = g_strdup(value); |
