fixed #123263, the encoding is mandatory in a textdecl. Daniel
* parser.c: fixed #123263, the encoding is mandatory in a textdecl.
Daniel
diff --git a/ChangeLog b/ChangeLog
index b92dc8f..10c9b28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Tue Oct 28 14:57:03 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c: fixed #123263, the encoding is mandatory in a textdecl.
+
Tue Oct 28 13:48:52 CET 2003 Daniel Veillard <daniel@veillard.com>
* tree.c: fix bug #125047 about serializing when finding a
diff --git a/include/libxml/xmlerror.h b/include/libxml/xmlerror.h
index 2def816..1fcdf96 100644
--- a/include/libxml/xmlerror.h
+++ b/include/libxml/xmlerror.h
@@ -181,6 +181,7 @@
XML_WAR_LANG_VALUE, /* 98 */
XML_WAR_NS_URI, /* 99 */
XML_WAR_NS_URI_RELATIVE, /* 100 */
+ XML_ERR_MISSING_ENCODING, /* 101 */
XML_NS_ERR_XML_NAMESPACE = 200,
XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */
XML_NS_ERR_QNAME, /* 202 */
diff --git a/parser.c b/parser.c
index bca57f8..edc2ee4 100644
--- a/parser.c
+++ b/parser.c
@@ -5592,6 +5592,7 @@
void
xmlParseTextDecl(xmlParserCtxtPtr ctxt) {
xmlChar *version;
+ const xmlChar *encoding;
/*
* We know that '<?xml' is here.
@@ -5626,13 +5627,17 @@
/*
* We must have the encoding declaration
*/
- xmlParseEncodingDecl(ctxt);
+ encoding = xmlParseEncodingDecl(ctxt);
if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
/*
* The XML REC instructs us to stop parsing right here
*/
return;
}
+ if ((encoding == NULL) && (ctxt->errNo == XML_ERR_OK)) {
+ xmlFatalErrMsg(ctxt, XML_ERR_MISSING_ENCODING,
+ "Missing encoding in text declaration\n");
+ }
SKIP_BLANKS;
if ((RAW == '?') && (NXT(1) == '>')) {