libxml2 r3730 - trunk



Author: veillard
Date: Thu Apr  3 13:59:06 2008
New Revision: 3730
URL: http://svn.gnome.org/viewvc/libxml2?rev=3730&view=rev

Log:
* parser.c: patch from Mark Rowe fixing BOM or encoding detection
  in external parsed entities, should fix #440415
Daniel


Modified:
   trunk/ChangeLog
   trunk/parser.c

Modified: trunk/parser.c
==============================================================================
--- trunk/parser.c	(original)
+++ trunk/parser.c	Thu Apr  3 13:59:06 2008
@@ -6059,6 +6059,21 @@
                        const xmlChar *SystemID) {
     xmlDetectSAX2(ctxt);
     GROW;
+
+    if ((ctxt->encoding == (const xmlChar *)XML_CHAR_ENCODING_NONE) &&
+        (ctxt->input->end - ctxt->input->cur >= 4)) {
+        xmlChar start[4];
+	xmlCharEncoding enc;
+
+	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 (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) {
 	xmlParseTextDecl(ctxt);
 	if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]