diff --git a/ChangeLog b/ChangeLog index fff87cb5..b272fd67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Oct 16 15:14:53 CEST 2006 Daniel Veillard + + * HTMLparser.c: fix #348252 if the document clains to be in a + different encoding in the meta tag and it's obviously wrong, + don't screw up the end of the content. + Mon Oct 16 11:32:09 CEST 2006 Daniel Veillard * HTMLparser.c: fix a chunking and script bug #347708 diff --git a/HTMLparser.c b/HTMLparser.c index 946e807d..1719c4c4 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -3291,7 +3291,18 @@ htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) { * registered set of known encodings */ if (enc != XML_CHAR_ENCODING_ERROR) { - xmlSwitchEncoding(ctxt, enc); + if (((enc == XML_CHAR_ENCODING_UTF16LE) || + (enc == XML_CHAR_ENCODING_UTF16BE) || + (enc == XML_CHAR_ENCODING_UCS4LE) || + (enc == XML_CHAR_ENCODING_UCS4BE)) && + (ctxt->input->buf != NULL) && + (ctxt->input->buf->encoder == NULL)) { + htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING, + "htmlCheckEncoding: wrong encoding meta\n", + NULL, NULL); + } else { + xmlSwitchEncoding(ctxt, enc); + } ctxt->charset = XML_CHAR_ENCODING_UTF8; } else { /*