mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
don't override existing encoding specified before starting
* parser.c: don't override existing encoding specified before starting xmlParseDocument() Daniel
This commit is contained in:
26
parser.c
26
parser.c
@ -7297,18 +7297,20 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
|
||||
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
|
||||
ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
|
||||
|
||||
/*
|
||||
* Get the 4 first bytes and decode the charset
|
||||
* if enc != XML_CHAR_ENCODING_NONE
|
||||
* plug some encoding conversion routines.
|
||||
*/
|
||||
start[0] = RAW;
|
||||
start[1] = NXT(1);
|
||||
start[2] = NXT(2);
|
||||
start[3] = NXT(3);
|
||||
enc = xmlDetectCharEncoding(start, 4);
|
||||
if (enc != XML_CHAR_ENCODING_NONE) {
|
||||
xmlSwitchEncoding(ctxt, enc);
|
||||
if (ctxt->encoding == XML_CHAR_ENCODING_NONE) {
|
||||
/*
|
||||
* Get the 4 first bytes and decode the charset
|
||||
* if enc != XML_CHAR_ENCODING_NONE
|
||||
* plug some encoding conversion routines.
|
||||
*/
|
||||
start[0] = RAW;
|
||||
start[1] = NXT(1);
|
||||
start[2] = NXT(2);
|
||||
start[3] = NXT(3);
|
||||
enc = xmlDetectCharEncoding(start, 4);
|
||||
if (enc != XML_CHAR_ENCODING_NONE) {
|
||||
xmlSwitchEncoding(ctxt, enc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user