1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +03:00

Fix HTML serialization with UTF-8 encoding

If the encoding is specified as UTF-8, make sure to use a NULL encoding
handler.
This commit is contained in:
Nick Wellnhofer
2018-10-13 16:12:14 +02:00
parent ee501f5449
commit d459831c1b

View File

@@ -502,8 +502,7 @@ htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc,
if (handler == NULL)
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
}
}
} else {
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
@@ -511,6 +510,7 @@ htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc,
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
}
/*
* save the content to a temp buffer.
@@ -575,11 +575,8 @@ htmlDocDumpMemoryFormat(xmlDocPtr cur, xmlChar**mem, int *size, int format) {
if (handler == NULL)
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
}
} else {
handler = xmlFindCharEncodingHandler(encoding);
}
}
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
@@ -587,6 +584,7 @@ htmlDocDumpMemoryFormat(xmlDocPtr cur, xmlChar**mem, int *size, int format) {
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
}
buf = xmlAllocOutputBufferInternal(handler);
if (buf == NULL) {
@@ -1096,11 +1094,8 @@ htmlDocDump(FILE *f, xmlDocPtr cur) {
handler = xmlFindCharEncodingHandler(encoding);
if (handler == NULL)
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
}
} else {
handler = xmlFindCharEncodingHandler(encoding);
}
}
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
@@ -1108,6 +1103,7 @@ htmlDocDump(FILE *f, xmlDocPtr cur) {
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
}
buf = xmlOutputBufferCreateFile(f, handler);
if (buf == NULL) return(-1);
@@ -1149,8 +1145,7 @@ htmlSaveFile(const char *filename, xmlDocPtr cur) {
if (handler == NULL)
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
}
}
} else {
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
@@ -1158,6 +1153,7 @@ htmlSaveFile(const char *filename, xmlDocPtr cur) {
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
}
/*
* save the content to a temp buffer.
@@ -1206,7 +1202,6 @@ htmlSaveFileFormat(const char *filename, xmlDocPtr cur,
htmlSetMetaEncoding(cur, (const xmlChar *) encoding);
} else {
htmlSetMetaEncoding(cur, (const xmlChar *) "UTF-8");
}
/*
* Fallback to HTML or ASCII when the encoding is unspecified
@@ -1215,6 +1210,7 @@ htmlSaveFileFormat(const char *filename, xmlDocPtr cur,
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
}
/*
* save the content to a temp buffer.