Title: [153553] trunk
Revision
153553
Author
[email protected]
Date
2013-07-31 17:51:39 -0700 (Wed, 31 Jul 2013)

Log Message

Reuse of XMLHttpRequests causes character corruption in response text
https://bugs.webkit.org/show_bug.cgi?id=119358

Reviewed by Anders Carlsson.

Source/WebCore:

Merge https://chromium.googlesource.com/chromium/blink/+/6496e7bb9a0b46bc79032b86d5993b25f127a4cb

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

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::clearResponseBuffers):
(WebCore::XMLHttpRequest::didFinishLoading):

LayoutTests:

* http/tests/xmlhttprequest/reopen-encoding-expected.txt: Added.
* http/tests/xmlhttprequest/reopen-encoding.html: Added.
* http/tests/xmlhttprequest/resources/get-utf-8.cgi: Added.
* http/tests/xmlhttprequest/resources/get-windows-1251.cgi: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (153552 => 153553)


--- trunk/LayoutTests/ChangeLog	2013-08-01 00:28:05 UTC (rev 153552)
+++ trunk/LayoutTests/ChangeLog	2013-08-01 00:51:39 UTC (rev 153553)
@@ -1,3 +1,15 @@
+2013-07-31  Ryosuke Niwa  <[email protected]>
+
+        Reuse of XMLHttpRequests causes character corruption in response text
+        https://bugs.webkit.org/show_bug.cgi?id=119358
+
+        Reviewed by Anders Carlsson.
+
+        * http/tests/xmlhttprequest/reopen-encoding-expected.txt: Added.
+        * http/tests/xmlhttprequest/reopen-encoding.html: Added.
+        * http/tests/xmlhttprequest/resources/get-utf-8.cgi: Added.
+        * http/tests/xmlhttprequest/resources/get-windows-1251.cgi: Added.
+
 2013-07-31  Mark Lam  <[email protected]>
 
         Bot greening.

Added: trunk/LayoutTests/http/tests/xmlhttprequest/reopen-encoding-expected.txt (0 => 153553)


--- trunk/LayoutTests/http/tests/xmlhttprequest/reopen-encoding-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/reopen-encoding-expected.txt	2013-08-01 00:51:39 UTC (rev 153553)
@@ -0,0 +1,13 @@
+This test verifies that XMLHttpRequest properly handles Content-Type when it is reused.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS req.getResponseHeader('Content-Type') is "text/plain; charset=utf-8"
+PASS req.responseText is "Проверка"
+PASS req.getResponseHeader('Content-Type') is "text/plain; charset=windows-1251"
+PASS req.responseText is "Проверка"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/xmlhttprequest/reopen-encoding.html (0 => 153553)


--- trunk/LayoutTests/http/tests/xmlhttprequest/reopen-encoding.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/reopen-encoding.html	2013-08-01 00:51:39 UTC (rev 153553)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+</head>
+<body>
+<script src=""
+<script>
+    description('This test verifies that XMLHttpRequest properly handles Content-Type when it is reused.');
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    var req = new XMLHttpRequest;
+    try {
+        req.open("GET", "resources/get-utf-8.cgi", false);
+        req.send();
+        shouldBeEqualToString("req.getResponseHeader('Content-Type')", "text/plain; charset=utf-8");
+        shouldBeEqualToString("req.responseText", "Проверка");
+        req.open("GET", "resources/get-windows-1251.cgi", false);
+        req.send();
+        shouldBeEqualToString("req.getResponseHeader('Content-Type')", "text/plain; charset=windows-1251");
+        shouldBeEqualToString("req.responseText", "Проверка");
+        finishJSTest();
+    } catch (ex) {
+        fail("an exception is thrown: " + ex);
+    }
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/xmlhttprequest/resources/get-utf-8.cgi (0 => 153553)


--- trunk/LayoutTests/http/tests/xmlhttprequest/resources/get-utf-8.cgi	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/resources/get-utf-8.cgi	2013-08-01 00:51:39 UTC (rev 153553)
@@ -0,0 +1,6 @@
+#!/usr/bin/perl -w
+use utf8;
+use Encode 'encode';
+
+print "Content-type: text/plain; charset=utf-8\n\n";
+print encode("UTF-8", "Проверка");
Property changes on: trunk/LayoutTests/http/tests/xmlhttprequest/resources/get-utf-8.cgi
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/http/tests/xmlhttprequest/resources/get-windows-1251.cgi (0 => 153553)


--- trunk/LayoutTests/http/tests/xmlhttprequest/resources/get-windows-1251.cgi	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/resources/get-windows-1251.cgi	2013-08-01 00:51:39 UTC (rev 153553)
@@ -0,0 +1,6 @@
+#!/usr/bin/perl -w
+use utf8;
+use Encode 'encode';
+
+print "Content-type: text/plain; charset=windows-1251\n\n";
+print encode("windows-1251", "Проверка");
Property changes on: trunk/LayoutTests/http/tests/xmlhttprequest/resources/get-windows-1251.cgi
___________________________________________________________________

Added: svn:executable

Modified: trunk/Source/WebCore/ChangeLog (153552 => 153553)


--- trunk/Source/WebCore/ChangeLog	2013-08-01 00:28:05 UTC (rev 153552)
+++ trunk/Source/WebCore/ChangeLog	2013-08-01 00:51:39 UTC (rev 153553)
@@ -1,3 +1,18 @@
+2013-07-31  Ryosuke Niwa  <[email protected]>
+
+        Reuse of XMLHttpRequests causes character corruption in response text
+        https://bugs.webkit.org/show_bug.cgi?id=119358
+
+        Reviewed by Anders Carlsson.
+
+        Merge https://chromium.googlesource.com/chromium/blink/+/6496e7bb9a0b46bc79032b86d5993b25f127a4cb
+
+        Test: http/tests/xmlhttprequest/reopen-encoding.html
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::clearResponseBuffers):
+        (WebCore::XMLHttpRequest::didFinishLoading):
+
 2013-07-31  Alexey Proskuryakov  <[email protected]>
 
         Make ActiveDOMObject overrides private

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (153552 => 153553)


--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2013-08-01 00:28:05 UTC (rev 153552)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2013-08-01 00:51:39 UTC (rev 153553)
@@ -885,6 +885,7 @@
 void XMLHttpRequest::clearResponseBuffers()
 {
     m_responseBuilder.clear();
+    m_responseEncoding = String();
     m_createdDocument = false;
     m_responseDocument = 0;
     m_responseBlob = 0;
@@ -1148,6 +1149,7 @@
     m_loader = 0;
 
     changeState(DONE);
+    m_responseEncoding = String();
     m_decoder = 0;
 
     if (hadLoader)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to