Diff
Modified: trunk/LayoutTests/ChangeLog (176929 => 176930)
--- trunk/LayoutTests/ChangeLog 2014-12-07 19:58:13 UTC (rev 176929)
+++ trunk/LayoutTests/ChangeLog 2014-12-07 20:05:17 UTC (rev 176930)
@@ -1,3 +1,22 @@
+2014-12-07 Youenn Fablet <[email protected]>
+
+ [Soup][Curl] HTTP header values should be treated as latin1, not UTF-8
+ https://bugs.webkit.org/show_bug.cgi?id=128739
+
+ Reviewed by Martin Robinson.
+
+ Tests that non ascii header & reason phrase values are correctly retrieved by the web application.
+ headers.php script sends a response that includes non ascii header value.
+ not-ascii-status.php sends a response that includes non ascii reason phrase.
+ Removed specific gtk/efl expectations as now aligned with regular expectation.
+
+ * http/tests/xmlhttprequest/resources/headers.php: Added.
+ * http/tests/xmlhttprequest/resources/not-ascii-status.php: Added.
+ * http/tests/xmlhttprequest/response-special-characters-expected.txt: Added.
+ * http/tests/xmlhttprequest/response-special-characters.html: Added.
+ * platform/efl/http/tests/security/contentSecurityPolicy/source-list-parsing-nonascii-expected.txt: Removed.
+ * platform/gtk/http/tests/security/contentSecurityPolicy/source-list-parsing-nonascii-expected.txt: Removed.
+
2014-12-07 Alexey Proskuryakov <[email protected]>
fast/borders/mixed-border-style2.html has missing results on Mac Yosemite.
Added: trunk/LayoutTests/http/tests/xmlhttprequest/resources/headers.php (0 => 176930)
--- trunk/LayoutTests/http/tests/xmlhttprequest/resources/headers.php (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/resources/headers.php 2014-12-07 20:05:17 UTC (rev 176930)
@@ -0,0 +1,11 @@
+<?php
+ header("Content-Type: text/plain");
+ header("X-Custom-Header: test");
+ header("Set-Cookie: test");
+ header("Set-Cookie2: test");
+ header("X-Custom-Header-Empty:");
+ header("X-Custom-Header-Comma: 1");
+ header("X-Custom-Header-Comma: 2", false);
+ header("X-Custom-Header-Bytes: …");
+ echo "TEST";
+?>
Added: trunk/LayoutTests/http/tests/xmlhttprequest/resources/not-ascii-status.php (0 => 176930)
--- trunk/LayoutTests/http/tests/xmlhttprequest/resources/not-ascii-status.php (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/resources/not-ascii-status.php 2014-12-07 20:05:17 UTC (rev 176930)
@@ -0,0 +1,4 @@
+<?php
+ header('HTTP/1.1 200 OK…');
+ echo "OK…";
+?>
Added: trunk/LayoutTests/http/tests/xmlhttprequest/response-special-characters-expected.txt (0 => 176930)
--- trunk/LayoutTests/http/tests/xmlhttprequest/response-special-characters-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/response-special-characters-expected.txt 2014-12-07 20:05:17 UTC (rev 176930)
@@ -0,0 +1,4 @@
+
+PASS non ascii response header value
+PASS non ascii statusText
+
Added: trunk/LayoutTests/http/tests/xmlhttprequest/response-special-characters.html (0 => 176930)
--- trunk/LayoutTests/http/tests/xmlhttprequest/response-special-characters.html (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/response-special-characters.html 2014-12-07 20:05:17 UTC (rev 176930)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>XMLHttpRequest: getting response with funny characters</title>
+ <script src=""
+ <script src=""
+ <!-- test file originating from W3C web platform test suite -->
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ function run_test(name, setupFunction, assertFunction)
+ {
+ var test = async_test(name)
+ test.isAsserted = false
+ test.step(function() {
+ var client = new XMLHttpRequest()
+ client._onreadystatechange_ = function() {
+ test.step(function() {
+ if(client.readyState == 4) {
+ test.isAsserted = true
+ assertFunction(client)
+ }
+ })
+ }
+ client._onloadend_ = function() {
+ assert_true(test.isAsserted)
+ test.done()
+ }
+ setupFunction(client)
+ client.send(null)
+ })
+ }
+
+ run_test("non ascii response header value",
+ function(client){
+ client.open("GET", "resources/headers.php")
+ },function(client){
+ assert_equals(client.getResponseHeader("x-custom-header-bytes"), "\xE2\x80\xA6")
+ }
+ )
+
+ run_test("non ascii statusText",
+ function(client){
+ client.open("GET", "resources/not-ascii-status.php")
+ },function(client){
+ assert_equals(client.statusText, "OK\xE2\x80\xA6")
+ }
+ )
+ </script>
+ </body>
+</html>
Deleted: trunk/LayoutTests/platform/efl/http/tests/security/contentSecurityPolicy/source-list-parsing-nonascii-expected.txt (176929 => 176930)
--- trunk/LayoutTests/platform/efl/http/tests/security/contentSecurityPolicy/source-list-parsing-nonascii-expected.txt 2014-12-07 19:58:13 UTC (rev 176929)
+++ trunk/LayoutTests/platform/efl/http/tests/security/contentSecurityPolicy/source-list-parsing-nonascii-expected.txt 2014-12-07 20:05:17 UTC (rev 176930)
@@ -1,9 +0,0 @@
-CONSOLE MESSAGE: The value for Content Security Policy directive 'script-src' contains an invalid character: '127.0.0.1/ßisnotSorB/'. Non-whitespace characters outside ASCII 0x21-0x7E must be percent-encoded, as described in RFC 3986, section 2.1: http://tools.ietf.org/html/rfc3986#section-2.1.
-Sources containing non-ascii characters should be ignored, and should generate warnings.
-
-
-
---------
-Frame: '<!--framePath //<!--frame0-->-->'
---------
-PASS
Deleted: trunk/LayoutTests/platform/gtk/http/tests/security/contentSecurityPolicy/source-list-parsing-nonascii-expected.txt (176929 => 176930)
--- trunk/LayoutTests/platform/gtk/http/tests/security/contentSecurityPolicy/source-list-parsing-nonascii-expected.txt 2014-12-07 19:58:13 UTC (rev 176929)
+++ trunk/LayoutTests/platform/gtk/http/tests/security/contentSecurityPolicy/source-list-parsing-nonascii-expected.txt 2014-12-07 20:05:17 UTC (rev 176930)
@@ -1,9 +0,0 @@
-CONSOLE MESSAGE: The value for Content Security Policy directive 'script-src' contains an invalid character: '127.0.0.1/ßisnotSorB/'. Non-whitespace characters outside ASCII 0x21-0x7E must be percent-encoded, as described in RFC 3986, section 2.1: http://tools.ietf.org/html/rfc3986#section-2.1.
-Sources containing non-ascii characters should be ignored, and should generate warnings.
-
-
-
---------
-Frame: '<!--framePath //<!--frame0-->-->'
---------
-PASS
Modified: trunk/Source/WebCore/ChangeLog (176929 => 176930)
--- trunk/Source/WebCore/ChangeLog 2014-12-07 19:58:13 UTC (rev 176929)
+++ trunk/Source/WebCore/ChangeLog 2014-12-07 20:05:17 UTC (rev 176930)
@@ -1,3 +1,31 @@
+2014-12-07 Youenn Fablet <[email protected]>
+
+ [Soup][Curl] HTTP header values should be treated as latin1, not UTF-8
+ https://bugs.webkit.org/show_bug.cgi?id=128739
+
+ Reviewed by Martin Robinson.
+
+ Removed UTF-8 conversion of HTTP header values (SOUP and CURL).
+ Removed unnecessary UTF-8 conversion of HTTP header names (SOUP).
+ Changed conversion of HTTP method from UTF-8 to ASCII (SOUP and CURL).
+ Added explicit UTF-8 conversion of Content-Disposition header to compute download suggested filename.
+
+ Test: http/tests/xmlhttprequest/response-special-characters.html
+
+ * platform/network/curl/CurlDownload.cpp:
+ (WebCore::CurlDownload::headerCallback): Removed header conversion.
+ * platform/network/curl/ResourceHandleManager.cpp:
+ (WebCore::headerCallback): Ditto.
+ (WebCore::ResourceHandleManager::initializeHandle): Changed HTTP method conversion to ASCI.
+ * platform/network/soup/ResourceRequestSoup.cpp:
+ (WebCore::ResourceRequest::updateFromSoupMessageHeaders): Removed header conversion.
+ (WebCore::ResourceRequest::updateSoupMessage): Changed HTTP method conversion to ASCII.
+ (WebCore::ResourceRequest::toSoupMessage): Ditto.
+ (WebCore::ResourceRequest::updateFromSoupMessage):
+ * platform/network/soup/ResourceResponseSoup.cpp:
+ (WebCore::ResourceResponse::updateFromSoupMessageHeaders): Rmoved header conversion.
+ (WebCore::ResourceResponse::platformSuggestedFilename): Added explicit conversion of contentDisposition to UTF-8.
+
2014-12-07 Dan Bernstein <[email protected]>
Introduce and deploy a function that allocates and returns an instance of a soft-linked class
Modified: trunk/Source/WebCore/platform/network/curl/CurlDownload.cpp (176929 => 176930)
--- trunk/Source/WebCore/platform/network/curl/CurlDownload.cpp 2014-12-07 19:58:13 UTC (rev 176929)
+++ trunk/Source/WebCore/platform/network/curl/CurlDownload.cpp 2014-12-07 20:05:17 UTC (rev 176930)
@@ -474,7 +474,7 @@
size_t totalSize = size * nmemb;
CurlDownload* download = reinterpret_cast<CurlDownload*>(data);
- String header = String::fromUTF8WithLatin1Fallback(static_cast<const char*>(ptr), totalSize);
+ String header(static_cast<const char*>(ptr), totalSize);
if (download)
download->didReceiveHeader(header);
Modified: trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp (176929 => 176930)
--- trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp 2014-12-07 19:58:13 UTC (rev 176929)
+++ trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp 2014-12-07 20:05:17 UTC (rev 176930)
@@ -473,7 +473,7 @@
size_t totalSize = size * nmemb;
ResourceHandleClient* client = d->client();
- String header = String::fromUTF8WithLatin1Fallback(static_cast<const char*>(ptr), totalSize);
+ String header(static_cast<const char*>(ptr), totalSize);
/*
* a) We can finish and send the ResourceResponse
@@ -1119,7 +1119,7 @@
else if ("HEAD" == method)
curl_easy_setopt(d->m_handle, CURLOPT_NOBODY, TRUE);
else {
- curl_easy_setopt(d->m_handle, CURLOPT_CUSTOMREQUEST, method.latin1().data());
+ curl_easy_setopt(d->m_handle, CURLOPT_CUSTOMREQUEST, method.ascii().data());
setupPUT(job, &headers);
}
Modified: trunk/Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp (176929 => 176930)
--- trunk/Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp 2014-12-07 19:58:13 UTC (rev 176929)
+++ trunk/Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp 2014-12-07 20:05:17 UTC (rev 176930)
@@ -65,12 +65,12 @@
const char* headerName;
const char* headerValue;
while (soup_message_headers_iter_next(&headersIter, &headerName, &headerValue))
- m_httpHeaderFields.set(String::fromUTF8(headerName), String::fromUTF8(headerValue));
+ m_httpHeaderFields.set(String(headerName), String(headerValue));
}
void ResourceRequest::updateSoupMessage(SoupMessage* soupMessage) const
{
- g_object_set(soupMessage, SOUP_MESSAGE_METHOD, httpMethod().utf8().data(), NULL);
+ g_object_set(soupMessage, SOUP_MESSAGE_METHOD, httpMethod().ascii().data(), NULL);
GUniquePtr<SoupURI> uri = createSoupURI();
soup_message_set_uri(soupMessage, uri.get());
@@ -80,7 +80,7 @@
SoupMessage* ResourceRequest::toSoupMessage() const
{
- SoupMessage* soupMessage = soup_message_new(httpMethod().utf8().data(), url().string().utf8().data());
+ SoupMessage* soupMessage = soup_message_new(httpMethod().ascii().data(), url().string().utf8().data());
if (!soupMessage)
return 0;
@@ -102,7 +102,7 @@
if (shouldPortBeResetToZero)
m_url.setPort(0);
- m_httpMethod = String::fromUTF8(soupMessage->method);
+ m_httpMethod = String(soupMessage->method);
updateFromSoupMessageHeaders(soupMessage->request_headers);
Modified: trunk/Source/WebCore/platform/network/soup/ResourceResponseSoup.cpp (176929 => 176930)
--- trunk/Source/WebCore/platform/network/soup/ResourceResponseSoup.cpp 2014-12-07 19:58:13 UTC (rev 176929)
+++ trunk/Source/WebCore/platform/network/soup/ResourceResponseSoup.cpp 2014-12-07 20:05:17 UTC (rev 176930)
@@ -87,7 +87,7 @@
soup_message_headers_iter_init(&headersIter, headers);
while (soup_message_headers_iter_next(&headersIter, &headerName, &headerValue))
- addHTTPHeaderField(String::fromUTF8WithLatin1Fallback(headerName, strlen(headerName)), String::fromUTF8WithLatin1Fallback(headerValue, strlen(headerValue)));
+ addHTTPHeaderField(String(headerName), String(headerValue));
String contentType;
const char* officialType = soup_message_headers_get_one(headers, "Content-Type");
@@ -108,7 +108,8 @@
String ResourceResponse::platformSuggestedFilename() const
{
- return filenameFromHTTPContentDisposition(httpHeaderField(HTTPHeaderName::ContentDisposition));
+ String contentDisposition(httpHeaderField(HTTPHeaderName::ContentDisposition));
+ return filenameFromHTTPContentDisposition(String::fromUTF8WithLatin1Fallback(contentDisposition.characters8(), contentDisposition.length()));
}
}