Parse version and encoding of the xml document.
authorlars <lars@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jul 2007 13:57:07 +0000 (13:57 +0000)
committerlars <lars@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jul 2007 13:57:07 +0000 (13:57 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24729 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/dom/XMLTokenizer.cpp

index d6f58ce9f93e74e0ff2ad36dc51c8dbcadc584a2..4e41b5a1e296a83459862990610f68e79cab3357 100644 (file)
@@ -1,3 +1,12 @@
+2007-07-27  Zack Rusin  <zack@kde.org>
+
+        Reviewed by Zack and Lars.
+
+        Parse version and encoding of the xml document.
+
+        * dom/XMLTokenizer.cpp:
+        (WebCore::XMLTokenizer::write):
+
 2007-07-27  Zack Rusin  <zack@kde.org>
 
         Reviewed by Zack and Lars.
index 42ed752f0954e463ee8c5b0725146be63fa2442d..187be79e63b57dcfe89a51c36d5123bb4b5b55ba 100644 (file)
@@ -583,8 +583,26 @@ bool XMLTokenizer::write(const SegmentedString& s, bool /*appendData*/)
         xmlParseChunk(m_context, reinterpret_cast<const char*>(parseString.characters()), sizeof(UChar) * parseString.length(), 0);
     }
 #else
-    if (parseString.length()) {
-        m_stream.addData(parseString);
+    QString data(parseString);
+    if (!data.isEmpty()) {
+        if (!m_sawFirstElement) {
+            int idx = data.indexOf(QLatin1String("<?xml"));
+            if (idx != -1) {
+                int start = idx + 5;
+                int end = data.indexOf(QLatin1String("?>"), start);
+                QString content = data.mid(start, end-start);
+                bool ok = true;
+                HashMap<String, String> attrs = parseAttributes(content, ok);
+                String version = attrs.get("version");
+                String encoding = attrs.get("encoding");
+                ExceptionCode ec = 0;
+                if (!version.isEmpty())
+                    m_doc->setXMLVersion(version, ec);
+                if (!encoding.isEmpty())
+                    m_doc->setXMLEncoding(encoding);
+            }
+        }
+        m_stream.addData(data);
         parse();
     }
 #endif