Reviewed by Darin.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Jan 2007 10:02:30 +0000 (10:02 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Jan 2007 10:02:30 +0000 (10:02 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=12389
        Chinese decoding error at hk.antispam.yahoo.com

        Test: fast/encoding/noscript-in-head.html

        * loader/TextResourceDecoder.cpp:
        (WebCore::TextResourceDecoder::checkForHeadCharset): We were already allowing
        NOSCRIPT tags in head, let's actually skip over their content.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@19185 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/encoding/noscript-in-head-expected.txt [new file with mode: 0644]
LayoutTests/fast/encoding/noscript-in-head.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/loader/TextResourceDecoder.cpp

index f096adb..c8df300 100644 (file)
@@ -1,3 +1,13 @@
+2007-01-27  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=12389
+        Chinese decoding error at hk.antispam.yahoo.com
+
+        * fast/encoding/noscript-in-head-expected.txt: Added.
+        * fast/encoding/noscript-in-head.html: Added.
+
 2007-01-25  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Maciej Stachowiak.
diff --git a/LayoutTests/fast/encoding/noscript-in-head-expected.txt b/LayoutTests/fast/encoding/noscript-in-head-expected.txt
new file mode 100644 (file)
index 0000000..c280596
--- /dev/null
@@ -0,0 +1,9 @@
+Test for bug 12389: Chinese decoding error at hk.antispam.yahoo.com
+
+You should see two identical lines below:
+
+雅虎香港
+
+雅虎香港
+
+
diff --git a/LayoutTests/fast/encoding/noscript-in-head.html b/LayoutTests/fast/encoding/noscript-in-head.html
new file mode 100644 (file)
index 0000000..bd8acd2
--- /dev/null
@@ -0,0 +1,17 @@
+<script language=javascript>
+</script><noscript><img src=about:blank><table></table><p></p></noscript><html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=big5">
+</head><body>
+<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=12389">bug 12389</a>:
+Chinese decoding error at hk.antispam.yahoo.com</p>
+<p>You should see two identical lines below:</p>
+<p>¶®ªê­»´ä</p>
+<p>&#38597;&#34382;&#39321;&#28207;</p>
+
+<script>
+if (window.layoutTestController)
+  layoutTestController.dumpAsText();
+</script>
+</body>
+</html>
index 6f6c5fd..3a881ce 100644 (file)
@@ -1,3 +1,16 @@
+2007-01-27  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        http://bugs.webkit.org/show_bug.cgi?id=12389
+        Chinese decoding error at hk.antispam.yahoo.com
+
+        Test: fast/encoding/noscript-in-head.html
+
+        * loader/TextResourceDecoder.cpp:
+        (WebCore::TextResourceDecoder::checkForHeadCharset): We were already allowing 
+        NOSCRIPT tags in head, let's actually skip over their content.
+
 2007-01-26  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Maciej Stachowiak.
         * platform/cf/RetainPtr.h:
         (WebCore::adoptCFReference):
 
->>>>>>> .r19171
 2007-01-26  Darin Adler  <darin@apple.com>
 
         Reviewed by Brady.
index 6af4fbf..0def80b 100644 (file)
@@ -487,8 +487,7 @@ bool TextResourceDecoder::checkForHeadCharset(const char* data, size_t len, bool
     // <http://bugs.webkit.org/show_bug.cgi?id=4560> and
     // <http://bugs.webkit.org/show_bug.cgi?id=12165>.
     
-    bool withinTitle = false;
-    bool withinScript = false;
+    AtomicStringImpl* enclosingTagName;
 
     const char* ptr = m_buffer.data();
     const char* pEnd = ptr + m_buffer.size();
@@ -548,10 +547,17 @@ bool TextResourceDecoder::checkForHeadCharset(const char* data, size_t len, bool
             tmp[len] = 0;
             AtomicString tag(tmp);
             
-            if (tag == titleTag)
-                withinTitle = !end;
-            else if (tag == scriptTag)
-                withinScript = !end;
+            if (enclosingTagName) {
+                if (end && tag.impl() == enclosingTagName)
+                    enclosingTagName = 0;
+            } else {
+                if (tag == titleTag)
+                    enclosingTagName = titleTag.localName().impl();
+                else if (tag == scriptTag)
+                    enclosingTagName = scriptTag.localName().impl();
+                else if (tag == noscriptTag)
+                    enclosingTagName = noscriptTag.localName().impl();
+            }
             
             if (!end && tag == metaTag) {
                 const char* end = ptr;
@@ -597,7 +603,7 @@ bool TextResourceDecoder::checkForHeadCharset(const char* data, size_t len, bool
             } else if (tag != scriptTag && tag != noscriptTag && tag != styleTag &&
                        tag != linkTag && tag != metaTag && tag != objectTag &&
                        tag != titleTag && tag != baseTag && 
-                       (end || tag != htmlTag) && !withinTitle && !withinScript &&
+                       (end || tag != htmlTag) && !enclosingTagName &&
                        (tag != headTag) && isalpha(tmp[0])) {
                 m_checkedForHeadCharset = true;
                 return true;