Reviewed by Oliver.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Dec 2007 11:00:42 +0000 (11:00 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Dec 2007 11:00:42 +0000 (11:00 +0000)
        <rdar://problem/5629995> Incorrect display of Danish characters on web site.

        Test: http/tests/xmlhttprequest/response-encoding.html

        * xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::didReceiveData):
        Default to UTF-8 for HTML, too. It's unfortunate that we have to use different
        rules for main content and XHR responses, but this matches both IE and Firefox.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/xmlhttprequest/resources/utf-8-no-charset.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/response-encoding-expected.txt
LayoutTests/http/tests/xmlhttprequest/response-encoding.html
WebCore/ChangeLog
WebCore/xml/XMLHttpRequest.cpp

index 512db2df8910bc1c705bd5e862f037e3749030d1..724d1df605ed83e5a2b87e29994ea15f9b01bf59 100644 (file)
@@ -1,3 +1,13 @@
+2007-12-21  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Oliver.
+
+        <rdar://problem/5629995> Incorrect display of Danish characters on web site.
+
+        * http/tests/xmlhttprequest/resources/utf-8-no-charset.html: Added.
+        * http/tests/xmlhttprequest/response-encoding-expected.txt:
+        * http/tests/xmlhttprequest/response-encoding.html:
+
 2007-12-20  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by Oliver Hunt.
diff --git a/LayoutTests/http/tests/xmlhttprequest/resources/utf-8-no-charset.html b/LayoutTests/http/tests/xmlhttprequest/resources/utf-8-no-charset.html
new file mode 100644 (file)
index 0000000..b6dd67d
--- /dev/null
@@ -0,0 +1,3 @@
+<html>
+<body>Проверка</body>
+</html>
index f11ce70f6b5e333438b132e96f1623711bdf2a1f..40f0450f1496f9088c1709e4c745c499df22feb8 100644 (file)
@@ -10,6 +10,7 @@ XML, koi8-r specified in XML declaration, but overridden by windows-1251 in HTTP
 XML, koi8-r specified in XML declaration, but overridden by windows-1251 in overrideMimeType: Проверка. responseText: <?xml version="1.0" encoding="koi8-r"?> <node>Проверка</node>
 XML transferred as text/plain, UTF-8 as default (ignore XML text declaration): <?xml version="1.0" encoding="koi8-r"?> <node>Проверка</node>
 HTML, charset determined by a META: Проверка
+HTML, UTF-8 as default: Проверка
 Async: Plain text, UTF-8 as default: Проверка
 Async: Plain text, windows-1251 specified in HTTP headers: Проверка
 Async: Plain text, windows-1251 specified in overrideMimeType: Проверка
@@ -20,3 +21,4 @@ Async: XML, koi8-r specified in XML declaration, but overridden by windows-1251
 Async: XML, koi8-r specified in XML declaration, but overridden by windows-1251 in overrideMimeType: Проверка. responseText: <?xml version="1.0" encoding="koi8-r"?> <node>Проверка</node>
 Async: XML transferred as text/plain, UTF-8 as default (ignore XML text declaration): <?xml version="1.0" encoding="koi8-r"?> <node>Проверка</node>
 Async: HTML, charset determined by a META: Проверка
+Async: HTML, UTF-8 as default: Проверка
index 0070d223d5bc798285e93c635f8e557680606e4f..3050905d1507e37b0eb78ddc9cc8528771863cab 100644 (file)
              log("Async: XML transferred as text/plain, UTF-8 as default (ignore XML text declaration): " + req.responseText);
              get('resources/1251.html', true);
            } else if (asyncStep == 10) {
+             asyncStep = 11;
              log("Async: HTML, charset determined by a META: " + req.responseText.replace(/\s/g, "").replace(/.*<body>(.*)<\/body>.*/, "$1"));
+             get('resources/utf-8-no-charset.html', true);
+           } else if (asyncStep == 11) {
+             log("Async: HTML, UTF-8 as default: " + req.responseText.replace(/\s/g, "").replace(/.*<body>(.*)<\/body>.*/, "$1"));
            }
         } else {
            log("Error loading URL: status " + req.status);
         log("Exception: " + ex.description);
     }
 
+    // 11
+    try {
+        req =  get('resources/utf-8-no-charset.html', false);
+        log("HTML, UTF-8 as default: " + req.responseText.replace(/\s/g, "").replace(/.*<body>(.*)<\/body>.*/, "$1"));
+    } catch (ex) {
+        log("Exception: " + ex.description);
+    }
+
     // start async steps
     get('resources/reply.txt', true);
     
index 3c5bdb03fa9073fbfa250d0fd9a6dedb7c29bf9c..81f8ce486b694053a2f3ba9e6ed15a19fba16146 100644 (file)
@@ -1,3 +1,15 @@
+2007-12-21  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Oliver.
+
+        <rdar://problem/5629995> Incorrect display of Danish characters on web site.
+
+        Test: http/tests/xmlhttprequest/response-encoding.html
+
+        * xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::didReceiveData):
+        Default to UTF-8 for HTML, too. It's unfortunate that we have to use different
+        rules for main content and XHR responses, but this matches both IE and Firefox.
+
 2007-12-20  Jon Honeycutt  <jhoneycutt@apple.com>
 
         Reviewed by Kevin Decker.
index 1061f966ca126eef04158b94abd1e1659c9d4292..f115daf4e20c5052e9f1a2a708c8cdc80f9a7186 100644 (file)
@@ -729,7 +729,7 @@ void XMLHttpRequest::didReceiveData(SubresourceLoader*, const char* data, int le
         else if (responseIsXML())
             m_decoder = new TextResourceDecoder("application/xml");
         else if (responseMIMEType() == "text/html")
-            m_decoder = new TextResourceDecoder("text/html");
+            m_decoder = new TextResourceDecoder("text/html", "UTF-8");
         else
             m_decoder = new TextResourceDecoder("text/plain", "UTF-8");
     }