diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2008-02-15 08:33:21 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2008-02-15 08:33:21 +0000 |
commit | 6f8611fdb429a3423d4780ad49132bfe88d50a8c (patch) | |
tree | 3025fdffad80661b79632a13011e0bac48f89c33 /tree.c | |
parent | 8e1a46d526a3b8912437e80cb977e0608eabd0d7 (diff) | |
download | android_external_libxml2-6f8611fdb429a3423d4780ad49132bfe88d50a8c.tar.gz android_external_libxml2-6f8611fdb429a3423d4780ad49132bfe88d50a8c.tar.bz2 android_external_libxml2-6f8611fdb429a3423d4780ad49132bfe88d50a8c.zip |
patch from Julien Charbon to simplify the processing of xmlSetProp()
* include/libxml/xmlerror.h tree.c: patch from Julien Charbon
to simplify the processing of xmlSetProp()
Daniel
svn path=/trunk/; revision=3694
Diffstat (limited to 'tree.c')
-rw-r--r-- | tree.c | 25 |
1 files changed, 17 insertions, 8 deletions
@@ -92,6 +92,9 @@ xmlTreeErr(int code, xmlNodePtr node, const char *extra) case XML_TREE_UNTERMINATED_ENTITY: msg = "unterminated entity reference %15s\n"; break; + case XML_TREE_NOT_UTF8: + msg = "string is not in UTF-8\n"; + break; default: msg = "unexpected error number\n"; } @@ -1814,11 +1817,15 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns, cur->name = name; if (value != NULL) { - xmlChar *buffer; xmlNodePtr tmp; - buffer = xmlEncodeEntitiesReentrant(doc, value); - cur->children = xmlStringGetNodeList(doc, buffer); + if(!xmlCheckUTF8(value)) { + xmlTreeErr(XML_TREE_NOT_UTF8, (xmlNodePtr) doc, + NULL); + if (doc != NULL) + doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1"); + } + cur->children = xmlNewDocText(doc, value); cur->last = NULL; tmp = cur->children; while (tmp != NULL) { @@ -1827,7 +1834,6 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns, cur->last = tmp; tmp = tmp->next; } - xmlFree(buffer); } /* @@ -6466,11 +6472,15 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, prop->last = NULL; prop->ns = ns; if (value != NULL) { - xmlChar *buffer; xmlNodePtr tmp; - buffer = xmlEncodeEntitiesReentrant(node->doc, value); - prop->children = xmlStringGetNodeList(node->doc, buffer); + if(!xmlCheckUTF8(value)) { + xmlTreeErr(XML_TREE_NOT_UTF8, (xmlNodePtr) node->doc, + NULL); + if (node->doc != NULL) + node->doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1"); + } + prop->children = xmlNewDocText(node->doc, value); prop->last = NULL; tmp = prop->children; while (tmp != NULL) { @@ -6479,7 +6489,6 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, prop->last = tmp; tmp = tmp->next; } - xmlFree(buffer); } if (prop->atype == XML_ATTRIBUTE_ID) xmlAddID(NULL, node->doc, value, prop); |