mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
Stop checking attributes for UTF-8 validity
I can't see a reason to check attribute content for UTF-8 validity.
Other parts of the API like xmlNewText have always assumed valid UTF-8
as extra checks only slow down processing.
Besides, setting doc->encoding to "ISO-8859-1" seems pointless, and not
freeing the old encoding would cause a memory leak.
Note that this was last changed in 2008 with commit 6f8611fd which
removed unnecessary encoding/decoding steps. Setting attributes should
be even faster now.
Found by OSS-Fuzz.
This commit is contained in:
12
tree.c
12
tree.c
@@ -1901,12 +1901,6 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
|
|||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
xmlNodePtr tmp;
|
xmlNodePtr tmp;
|
||||||
|
|
||||||
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->children = xmlNewDocText(doc, value);
|
||||||
cur->last = NULL;
|
cur->last = NULL;
|
||||||
tmp = cur->children;
|
tmp = cur->children;
|
||||||
@@ -6945,12 +6939,6 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
|
|||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
xmlNodePtr tmp;
|
xmlNodePtr tmp;
|
||||||
|
|
||||||
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->children = xmlNewDocText(node->doc, value);
|
||||||
prop->last = NULL;
|
prop->last = NULL;
|
||||||
tmp = prop->children;
|
tmp = prop->children;
|
||||||
|
|||||||
Reference in New Issue
Block a user