Title: [200776] trunk/Source/WebCore
Revision
200776
Author
[email protected]
Date
2016-05-12 09:21:07 -0700 (Thu, 12 May 2016)

Log Message

[curl] ASSERTION FAILED: isLocalFile() || url == m_string in fast/dom/34176.html
https://bugs.webkit.org/show_bug.cgi?id=157059

Patch by Fujii Hironori <[email protected]> on 2016-05-12
Reviewed by Darin Adler.

Fix incorrect usage of URL constructor. CURLINFO_EFFECTIVE_URL
does not conform to URL's ParsedURLString.  Created a new utility
function to convert CURLINFO_EFFECTIVE_URL to a URL, and replaced
all codes converting CURLINFO_EFFECTIVE_URL with it.

Test: fast/dom/34176.html

* platform/network/curl/CurlDownload.cpp:
(WebCore::CurlDownload::didReceiveHeader): Use getCurlEffectiveURL
* platform/network/curl/ResourceHandleManager.cpp:
(WebCore::getCurlEffectiveURL): Added.
(WebCore::handleLocalReceiveResponse): Use getCurlEffectiveURL
(WebCore::getProtectionSpace): Ditto.
(WebCore::headerCallback): Ditto.
(WebCore::ResourceHandleManager::downloadTimerCallback): Ditto.
* platform/network/curl/ResourceHandleManager.h: Add a declaration
of getCurlEffectiveURL.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (200775 => 200776)


--- trunk/Source/WebCore/ChangeLog	2016-05-12 16:07:13 UTC (rev 200775)
+++ trunk/Source/WebCore/ChangeLog	2016-05-12 16:21:07 UTC (rev 200776)
@@ -1,3 +1,28 @@
+2016-05-12  Fujii Hironori  <[email protected]>
+
+        [curl] ASSERTION FAILED: isLocalFile() || url == m_string in fast/dom/34176.html
+        https://bugs.webkit.org/show_bug.cgi?id=157059
+
+        Reviewed by Darin Adler.
+
+        Fix incorrect usage of URL constructor. CURLINFO_EFFECTIVE_URL
+        does not conform to URL's ParsedURLString.  Created a new utility
+        function to convert CURLINFO_EFFECTIVE_URL to a URL, and replaced
+        all codes converting CURLINFO_EFFECTIVE_URL with it.
+
+        Test: fast/dom/34176.html
+
+        * platform/network/curl/CurlDownload.cpp:
+        (WebCore::CurlDownload::didReceiveHeader): Use getCurlEffectiveURL
+        * platform/network/curl/ResourceHandleManager.cpp:
+        (WebCore::getCurlEffectiveURL): Added.
+        (WebCore::handleLocalReceiveResponse): Use getCurlEffectiveURL
+        (WebCore::getProtectionSpace): Ditto.
+        (WebCore::headerCallback): Ditto.
+        (WebCore::ResourceHandleManager::downloadTimerCallback): Ditto.
+        * platform/network/curl/ResourceHandleManager.h: Add a declaration
+        of getCurlEffectiveURL.
+
 2016-05-12  Chris Dumez  <[email protected]>
 
         Avoid unnecessary null checks in toJS() when the implementation returns a reference or Ref<>

Modified: trunk/Source/WebCore/platform/network/curl/CurlDownload.cpp (200775 => 200776)


--- trunk/Source/WebCore/platform/network/curl/CurlDownload.cpp	2016-05-12 16:07:13 UTC (rev 200775)
+++ trunk/Source/WebCore/platform/network/curl/CurlDownload.cpp	2016-05-12 16:21:07 UTC (rev 200776)
@@ -402,17 +402,11 @@
         CURLcode err = curl_easy_getinfo(m_curlHandle, CURLINFO_RESPONSE_CODE, &httpCode);
 
         if (httpCode >= 200 && httpCode < 300) {
-            const char* url = ""
-            err = curl_easy_getinfo(m_curlHandle, CURLINFO_EFFECTIVE_URL, &url);
-
-            String strUrl(url);
-            StringCapture capturedUrl(strUrl);
-
+            URLCapture capturedUrl(getCurlEffectiveURL(m_curlHandle));
             RefPtr<CurlDownload> protectedDownload(this);
 
             callOnMainThread([this, capturedUrl, protectedDownload] {
-                m_response.setURL(URL(ParsedURLString, capturedUrl.string()));
-
+                m_response.setURL(capturedUrl.url());
                 m_response.setMimeType(extractMIMETypeFromMediaType(m_response.httpHeaderField(HTTPHeaderName::ContentType)));
                 m_response.setTextEncodingName(extractCharsetFromMediaType(m_response.httpHeaderField(HTTPHeaderName::ContentType)));
 

Modified: trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp (200775 => 200776)


--- trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp	2016-05-12 16:07:13 UTC (rev 200775)
+++ trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp	2016-05-12 16:21:07 UTC (rev 200776)
@@ -80,6 +80,15 @@
 const double pollTimeSeconds = 0.05;
 const int maxRunningJobs = 128;
 
+URL getCurlEffectiveURL(CURL* handle)
+{
+    const char* url;
+    CURLcode err = curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url);
+    if (CURLE_OK != err)
+        return URL();
+    return URL(URL(), url);
+}
+
 static const bool ignoreSSLErrors = getenv("WEBKIT_IGNORE_SSL_ERRORS");
 
 static CString certificatePath()
@@ -292,10 +301,9 @@
     // which means the ResourceLoader's response does not contain the URL.
     // Run the code here for local files to resolve the issue.
     // TODO: See if there is a better approach for handling this.
-     const char* hdr;
-     CURLcode err = curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &hdr);
-     ASSERT_UNUSED(err, CURLE_OK == err);
-     d->m_response.setURL(URL(ParsedURLString, hdr));
+    URL url = ""
+    ASSERT(url.isValid());
+    d->m_response.setURL(url);
      if (d->client())
          d->client()->didReceiveResponse(job, d->m_response);
      d->m_response.setResponseFired(true);
@@ -404,13 +412,10 @@
     if (err != CURLE_OK)
         return false;
 
-    const char* effectiveUrl = 0;
-    err = curl_easy_getinfo(h, CURLINFO_EFFECTIVE_URL, &effectiveUrl);
-    if (err != CURLE_OK)
+    URL url = ""
+    if (!url.isValid())
         return false;
 
-    URL url(ParsedURLString, effectiveUrl);
-
     String host = url.host();
     String protocol = url.protocol();
 
@@ -496,9 +501,7 @@
         curl_easy_getinfo(h, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &contentLength);
         d->m_response.setExpectedContentLength(static_cast<long long int>(contentLength));
 
-        const char* hdr;
-        curl_easy_getinfo(h, CURLINFO_EFFECTIVE_URL, &hdr);
-        d->m_response.setURL(URL(ParsedURLString, hdr));
+        d->m_response.setURL(getCurlEffectiveURL(h));
 
         d->m_response.setHTTPStatusCode(httpCode);
         d->m_response.setMimeType(extractMIMETypeFromMediaType(d->m_response.httpHeaderField(HTTPHeaderName::ContentType)).convertToASCIILowercase());
@@ -704,13 +707,12 @@
                 CurlCacheManager::getInstance().didFinishLoading(*job);
             }
         } else {
-            char* url = ""
-            curl_easy_getinfo(d->m_handle, CURLINFO_EFFECTIVE_URL, &url);
+            URL url = ""
 #ifndef NDEBUG
-            fprintf(stderr, "Curl ERROR for url='', error: '%s'\n", url, curl_easy_strerror(msg->data.result));
+            fprintf(stderr, "Curl ERROR for url='', error: '%s'\n", url.string().utf8().data(), curl_easy_strerror(msg->data.result));
 #endif
             if (d->client()) {
-                ResourceError resourceError(String(), msg->data.result, URL(ParsedURLString, String(url)), String(curl_easy_strerror(msg->data.result)));
+                ResourceError resourceError(String(), msg->data.result, url, String(curl_easy_strerror(msg->data.result)));
                 resourceError.setSSLErrors(d->m_sslErrors);
                 d->client()->didFail(job, resourceError);
                 CurlCacheManager::getInstance().didFail(*job);

Modified: trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.h (200775 => 200776)


--- trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.h	2016-05-12 16:07:13 UTC (rev 200775)
+++ trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.h	2016-05-12 16:21:07 UTC (rev 200776)
@@ -104,6 +104,8 @@
 #endif
 };
 
+URL getCurlEffectiveURL(CURL*);
+
 }
 
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to