libxml2 r3694 - in trunk: . include/libxml
- From: veillard svn gnome org
- To: svn-commits-list gnome org
- Subject: libxml2 r3694 - in trunk: . include/libxml
- Date: Fri, 15 Feb 2008 08:33:22 +0000 (GMT)
Author: veillard
Date: Fri Feb 15 08:33:21 2008
New Revision: 3694
URL: http://svn.gnome.org/viewvc/libxml2?rev=3694&view=rev
Log:
* include/libxml/xmlerror.h tree.c: patch from Julien Charbon
to simplify the processing of xmlSetProp()
Daniel
Modified:
trunk/ChangeLog
trunk/include/libxml/xmlerror.h
trunk/tree.c
Modified: trunk/include/libxml/xmlerror.h
==============================================================================
--- trunk/include/libxml/xmlerror.h (original)
+++ trunk/include/libxml/xmlerror.h Fri Feb 15 08:33:21 2008
@@ -398,6 +398,7 @@
XML_TREE_INVALID_HEX = 1300,
XML_TREE_INVALID_DEC, /* 1301 */
XML_TREE_UNTERMINATED_ENTITY, /* 1302 */
+ XML_TREE_NOT_UTF8, /* 1303 */
XML_SAVE_NOT_UTF8 = 1400,
XML_SAVE_CHAR_INVALID, /* 1401 */
XML_SAVE_NO_DOCTYPE, /* 1402 */
Modified: trunk/tree.c
==============================================================================
--- trunk/tree.c (original)
+++ trunk/tree.c Fri Feb 15 08:33:21 2008
@@ -92,6 +92,9 @@
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 @@
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 @@
cur->last = tmp;
tmp = tmp->next;
}
- xmlFree(buffer);
}
/*
@@ -6466,11 +6472,15 @@
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 @@
prop->last = tmp;
tmp = tmp->next;
}
- xmlFree(buffer);
}
if (prop->atype == XML_ATTRIBUTE_ID)
xmlAddID(NULL, node->doc, value, prop);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]