mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
Stop using doc->charset outside parser code
doc->charset does not specify the in-memory encoding which is always UTF-8.
This commit is contained in:
38
HTMLtree.c
38
HTMLtree.c
@@ -570,16 +570,7 @@ htmlDocDumpMemoryFormat(xmlDocPtr cur, xmlChar**mem, int *size, int format) {
|
|||||||
xmlCharEncoding enc;
|
xmlCharEncoding enc;
|
||||||
|
|
||||||
enc = xmlParseCharEncoding(encoding);
|
enc = xmlParseCharEncoding(encoding);
|
||||||
if (enc != cur->charset) {
|
if (enc != XML_CHAR_ENCODING_UTF8) {
|
||||||
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
|
|
||||||
/*
|
|
||||||
* Not supported yet
|
|
||||||
*/
|
|
||||||
*mem = NULL;
|
|
||||||
*size = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
handler = xmlFindCharEncodingHandler(encoding);
|
handler = xmlFindCharEncodingHandler(encoding);
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
|
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
|
||||||
@@ -1101,14 +1092,7 @@ htmlDocDump(FILE *f, xmlDocPtr cur) {
|
|||||||
xmlCharEncoding enc;
|
xmlCharEncoding enc;
|
||||||
|
|
||||||
enc = xmlParseCharEncoding(encoding);
|
enc = xmlParseCharEncoding(encoding);
|
||||||
if (enc != cur->charset) {
|
if (enc != XML_CHAR_ENCODING_UTF8) {
|
||||||
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
|
|
||||||
/*
|
|
||||||
* Not supported yet
|
|
||||||
*/
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
handler = xmlFindCharEncodingHandler(encoding);
|
handler = xmlFindCharEncodingHandler(encoding);
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
|
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
|
||||||
@@ -1160,14 +1144,7 @@ htmlSaveFile(const char *filename, xmlDocPtr cur) {
|
|||||||
xmlCharEncoding enc;
|
xmlCharEncoding enc;
|
||||||
|
|
||||||
enc = xmlParseCharEncoding(encoding);
|
enc = xmlParseCharEncoding(encoding);
|
||||||
if (enc != cur->charset) {
|
if (enc != XML_CHAR_ENCODING_UTF8) {
|
||||||
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
|
|
||||||
/*
|
|
||||||
* Not supported yet
|
|
||||||
*/
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
handler = xmlFindCharEncodingHandler(encoding);
|
handler = xmlFindCharEncodingHandler(encoding);
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
|
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
|
||||||
@@ -1221,14 +1198,7 @@ htmlSaveFileFormat(const char *filename, xmlDocPtr cur,
|
|||||||
xmlCharEncoding enc;
|
xmlCharEncoding enc;
|
||||||
|
|
||||||
enc = xmlParseCharEncoding(encoding);
|
enc = xmlParseCharEncoding(encoding);
|
||||||
if (enc != cur->charset) {
|
if (enc != XML_CHAR_ENCODING_UTF8) {
|
||||||
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
|
|
||||||
/*
|
|
||||||
* Not supported yet
|
|
||||||
*/
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
handler = xmlFindCharEncodingHandler(encoding);
|
handler = xmlFindCharEncodingHandler(encoding);
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
|
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
|
||||||
|
|||||||
9
c14n.c
9
c14n.c
@@ -1797,15 +1797,6 @@ xmlC14NNewCtx(xmlDocPtr doc,
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Validate the XML document encoding value, if provided.
|
|
||||||
*/
|
|
||||||
if (doc->charset != XML_CHAR_ENCODING_UTF8) {
|
|
||||||
xmlC14NErr(ctx, (xmlNodePtr) doc, XML_C14N_REQUIRES_UTF8,
|
|
||||||
"xmlC14NNewCtx: source document not in UTF8\n");
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate a new xmlC14NCtxPtr and fill the fields.
|
* Allocate a new xmlC14NCtxPtr and fill the fields.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -575,7 +575,7 @@ struct _xmlDoc {
|
|||||||
void *ids; /* Hash table for ID attributes if any */
|
void *ids; /* Hash table for ID attributes if any */
|
||||||
void *refs; /* Hash table for IDREFs attributes if any */
|
void *refs; /* Hash table for IDREFs attributes if any */
|
||||||
const xmlChar *URL; /* The URI for that document */
|
const xmlChar *URL; /* The URI for that document */
|
||||||
int charset; /* encoding of the in-memory content
|
int charset; /* Internal flag for charset handling,
|
||||||
actually an xmlCharEncoding */
|
actually an xmlCharEncoding */
|
||||||
struct _xmlDict *dict; /* dict used to allocate names or NULL */
|
struct _xmlDict *dict; /* dict used to allocate names or NULL */
|
||||||
void *psvi; /* for type/PSVI informations */
|
void *psvi; /* for type/PSVI informations */
|
||||||
|
|||||||
@@ -1123,9 +1123,6 @@ xmlDocContentDumpOutput(xmlSaveCtxtPtr ctxt, xmlDocPtr cur) {
|
|||||||
cur->encoding = BAD_CAST ctxt->encoding;
|
cur->encoding = BAD_CAST ctxt->encoding;
|
||||||
} else if (cur->encoding != NULL) {
|
} else if (cur->encoding != NULL) {
|
||||||
encoding = cur->encoding;
|
encoding = cur->encoding;
|
||||||
} else if (cur->charset != XML_CHAR_ENCODING_UTF8) {
|
|
||||||
encoding = (const xmlChar *)
|
|
||||||
xmlGetCharEncodingName((xmlCharEncoding) cur->charset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((cur->type == XML_HTML_DOCUMENT_NODE) &&
|
if (((cur->type == XML_HTML_DOCUMENT_NODE) &&
|
||||||
|
|||||||
Reference in New Issue
Block a user