[SOUP] Remove soupURIToKURL
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Jan 2014 09:08:40 +0000 (09:08 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Jan 2014 09:08:40 +0000 (09:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127104

Reviewed by Martin Robinson.

Source/WebCore:

In favor of a URL constructor receiving a SoupURI. Also add a
method to URL to create a soupURI.

* GNUmakefile.list.am: Remove SoupURIUtils and add URLSoup.
* PlatformEfl.cmake: Ditto.
* PlatformGTK.cmake: Ditto.
* platform/URL.h: Add URL constructor receiving a SoupURI and
createSoupURI() to create a new soupURI for the URL.
* platform/network/soup/CookieJarSoup.cpp:
(WebCore::setCookiesFromDOM): Use URL::createSoupURI().
(WebCore::cookiesForSession): Ditto.
(WebCore::getRawCookies): Ditto.
(WebCore::deleteCookie): Ditto.
* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::doRedirect): Use the new URL constructor instead of
soupURIToKURL.
(WebCore::createSoupRequestAndMessageForHandle): Use URL::createSoupURI().
* platform/network/soup/ResourceRequest.h: Rename soupURI as
createSoupURI to make it clear that the method returns a newly
created SoupURI.
* platform/network/soup/ResourceRequestSoup.cpp:
(WebCore::ResourceRequest::updateSoupMessageMembers): Use URL::createSoupURI().
(WebCore::ResourceRequest::updateSoupMessage): Ditto.
(WebCore::ResourceRequest::updateFromSoupMessage): Use the new URL
constructor instead of soupURIToKURL.
(WebCore::ResourceRequest::createSoupURI): Use URL::createSoupURI().
* platform/network/soup/ResourceResponseSoup.cpp:
(WebCore::ResourceResponse::updateFromSoupMessage): Use the new
URL constructor instead of soupURIToKURL.
* platform/network/soup/SoupURIUtils.cpp: Removed.
* platform/network/soup/SoupURIUtils.h: Removed.
* platform/soup/URLSoup.cpp: Added.
(WebCore::URL::URL):
(WebCore::URL::createSoupURI):

Tools:

* TestWebKitAPI/GNUmakefile.am: Add soup cppflags to WebCore unit
tests, because URL.h now includes GUniquePtrSoup.h.
* TestWebKitAPI/CMakeLists.txt: Ditto.
* WebKitTestRunner/PlatformEfl.cmake: Add soup cppflags to WTR,
because URL.h now includes GUniquePtrSoup.h.

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

17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/PlatformEfl.cmake
Source/WebCore/PlatformGTK.cmake
Source/WebCore/platform/URL.h
Source/WebCore/platform/network/soup/CookieJarSoup.cpp
Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
Source/WebCore/platform/network/soup/ResourceRequest.h
Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp
Source/WebCore/platform/network/soup/ResourceResponseSoup.cpp
Source/WebCore/platform/network/soup/SoupURIUtils.cpp [deleted file]
Source/WebCore/platform/network/soup/SoupURIUtils.h [deleted file]
Source/WebCore/platform/soup/URLSoup.cpp [new file with mode: 0644]
Tools/ChangeLog
Tools/TestWebKitAPI/CMakeLists.txt
Tools/TestWebKitAPI/GNUmakefile.am
Tools/WebKitTestRunner/PlatformEfl.cmake

index dda2e99..55988ef 100644 (file)
@@ -1,3 +1,45 @@
+2014-01-28  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [SOUP] Remove soupURIToKURL
+        https://bugs.webkit.org/show_bug.cgi?id=127104
+
+        Reviewed by Martin Robinson.
+
+        In favor of a URL constructor receiving a SoupURI. Also add a
+        method to URL to create a soupURI.
+
+        * GNUmakefile.list.am: Remove SoupURIUtils and add URLSoup.
+        * PlatformEfl.cmake: Ditto.
+        * PlatformGTK.cmake: Ditto.
+        * platform/URL.h: Add URL constructor receiving a SoupURI and
+        createSoupURI() to create a new soupURI for the URL.
+        * platform/network/soup/CookieJarSoup.cpp:
+        (WebCore::setCookiesFromDOM): Use URL::createSoupURI().
+        (WebCore::cookiesForSession): Ditto.
+        (WebCore::getRawCookies): Ditto.
+        (WebCore::deleteCookie): Ditto.
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::doRedirect): Use the new URL constructor instead of
+        soupURIToKURL.
+        (WebCore::createSoupRequestAndMessageForHandle): Use URL::createSoupURI().
+        * platform/network/soup/ResourceRequest.h: Rename soupURI as
+        createSoupURI to make it clear that the method returns a newly
+        created SoupURI.
+        * platform/network/soup/ResourceRequestSoup.cpp:
+        (WebCore::ResourceRequest::updateSoupMessageMembers): Use URL::createSoupURI().
+        (WebCore::ResourceRequest::updateSoupMessage): Ditto.
+        (WebCore::ResourceRequest::updateFromSoupMessage): Use the new URL
+        constructor instead of soupURIToKURL.
+        (WebCore::ResourceRequest::createSoupURI): Use URL::createSoupURI().
+        * platform/network/soup/ResourceResponseSoup.cpp:
+        (WebCore::ResourceResponse::updateFromSoupMessage): Use the new
+        URL constructor instead of soupURIToKURL.
+        * platform/network/soup/SoupURIUtils.cpp: Removed.
+        * platform/network/soup/SoupURIUtils.h: Removed.
+        * platform/soup/URLSoup.cpp: Added.
+        (WebCore::URL::URL):
+        (WebCore::URL::createSoupURI):
+
 2014-01-27  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Avoid unnecessary string duplications in FileSystemGtk
index e91c653..9bdc99e 100644 (file)
@@ -5866,8 +5866,6 @@ platform_sources += \
        Source/WebCore/platform/network/soup/SocketStreamError.h \
        Source/WebCore/platform/network/soup/SocketStreamHandle.h \
        Source/WebCore/platform/network/soup/SocketStreamHandleSoup.cpp \
-       Source/WebCore/platform/network/soup/SoupURIUtils.cpp \
-       Source/WebCore/platform/network/soup/SoupURIUtils.h \
        Source/WebCore/platform/network/AuthenticationChallengeBase.cpp \
        Source/WebCore/platform/network/AuthenticationChallengeBase.h \
        Source/WebCore/platform/network/AuthenticationClient.h \
@@ -5906,6 +5904,7 @@ platform_sources += \
        Source/WebCore/platform/network/SocketStreamHandleBase.h \
        Source/WebCore/platform/network/SocketStreamHandleClient.h \
        Source/WebCore/platform/soup/SharedBufferSoup.cpp \
+       Source/WebCore/platform/soup/URLSoup.cpp \
        Source/WebCore/platform/text/enchant/TextCheckerEnchant.h \
        Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp \
        Source/WebCore/platform/text/icu/UTextProvider.cpp \
index 996b76f..61fbff2 100644 (file)
@@ -167,13 +167,13 @@ list(APPEND WebCore_SOURCES
     platform/network/soup/ResourceResponseSoup.cpp
     platform/network/soup/SocketStreamHandleSoup.cpp
     platform/network/soup/SoupNetworkSession.cpp
-    platform/network/soup/SoupURIUtils.cpp
     platform/network/soup/SynchronousLoaderClientSoup.cpp
 
     platform/posix/FileSystemPOSIX.cpp
     platform/posix/SharedBufferPOSIX.cpp
 
     platform/soup/SharedBufferSoup.cpp
+    platform/soup/URLSoup.cpp
 
     platform/text/LocaleICU.cpp
 
index ff6e7ee..bf0f32f 100644 (file)
@@ -125,10 +125,10 @@ list(APPEND WebCore_SOURCES
     platform/network/soup/ResourceResponseSoup.cpp
     platform/network/soup/SocketStreamHandleSoup.cpp
     platform/network/soup/SoupNetworkSession.cpp
-    platform/network/soup/SoupURIUtils.cpp
     platform/network/soup/SynchronousLoaderClientSoup.cpp
 
     platform/soup/SharedBufferSoup.cpp
+    platform/soup/URLSoup.cpp
 
     platform/text/icu/UTextProvider.cpp
     platform/text/icu/UTextProviderLatin1.cpp
index 34993a3..8ab1377 100644 (file)
 typedef const struct __CFURL* CFURLRef;
 #endif
 
+#if USE(SOUP)
+#include "GUniquePtrSoup.h"
+#endif
+
 #if PLATFORM(MAC)
 OBJC_CLASS NSURL;
 #endif
@@ -160,6 +164,11 @@ public:
     RetainPtr<CFURLRef> createCFURL() const;
 #endif
 
+#if USE(SOUP)
+    URL(SoupURI*);
+    GUniquePtr<SoupURI> createSoupURI() const;
+#endif
+
 #if PLATFORM(MAC)
     URL(NSURL*);
     operator NSURL*() const;
index 8101e52..fec9dd5 100644 (file)
@@ -88,8 +88,8 @@ void setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstPar
     if (!jar)
         return;
 
-    GUniquePtr<SoupURI> origin(soup_uri_new(url.string().utf8().data()));
-    GUniquePtr<SoupURI> firstPartyURI(soup_uri_new(firstParty.string().utf8().data()));
+    GUniquePtr<SoupURI> origin = url.createSoupURI();
+    GUniquePtr<SoupURI> firstPartyURI = firstParty.createSoupURI();
 
     // Get existing cookies for this origin.
     GSList* existingCookies = soup_cookie_jar_get_cookie_list(jar, origin.get(), TRUE);
@@ -122,7 +122,7 @@ static String cookiesForSession(const NetworkStorageSession& session, const URL&
     if (!jar)
         return String();
 
-    GUniquePtr<SoupURI> uri(soup_uri_new(url.string().utf8().data()));
+    GUniquePtr<SoupURI> uri = url.createSoupURI();
     GUniquePtr<char> cookies(soup_cookie_jar_get_cookies(jar, uri.get(), forHTTPHeader));
     return String::fromUTF8(cookies.get());
 }
@@ -149,7 +149,7 @@ bool getRawCookies(const NetworkStorageSession& session, const URL& /*firstParty
     if (!jar)
         return false;
 
-    GUniquePtr<SoupURI> uri(soup_uri_new(url.string().utf8().data()));
+    GUniquePtr<SoupURI> uri = url.createSoupURI();
     GUniquePtr<GSList> cookies(soup_cookie_jar_get_cookie_list(jar, uri.get(), TRUE));
     if (!cookies)
         return false;
@@ -171,7 +171,7 @@ void deleteCookie(const NetworkStorageSession& session, const URL& url, const St
     if (!jar)
         return;
 
-    GUniquePtr<SoupURI> uri(soup_uri_new(url.string().utf8().data()));
+    GUniquePtr<SoupURI> uri = url.createSoupURI();
     GUniquePtr<GSList> cookies(soup_cookie_jar_get_cookie_list(jar, uri.get(), TRUE));
     if (!cookies)
         return;
index 6f2f7ad..29d777e 100644 (file)
@@ -44,7 +44,6 @@
 #include "ResourceResponse.h"
 #include "SharedBuffer.h"
 #include "SoupNetworkSession.h"
-#include "SoupURIUtils.h"
 #include "TextEncoding.h"
 #include <errno.h>
 #include <fcntl.h>
@@ -453,7 +452,7 @@ static void doRedirect(ResourceHandle* handle)
     ResourceRequest newRequest = handle->firstRequest();
     SoupMessage* message = d->m_soupMessage.get();
     const char* location = soup_message_headers_get_one(message->response_headers, "Location");
-    URL newURL = URL(soupURIToKURL(soup_message_get_uri(message)), location);
+    URL newURL = URL(URL(soup_message_get_uri(message)), location);
     bool crossOrigin = !protocolHostAndPortAreEqual(handle->firstRequest().url(), newURL);
     newRequest.setURL(newURL);
     newRequest.setFirstPartyForCookies(newURL);
@@ -981,7 +980,7 @@ static bool createSoupRequestAndMessageForHandle(ResourceHandle* handle, const R
 
     GOwnPtr<GError> error;
 
-    GUniquePtr<SoupURI> soupURI(request.soupURI());
+    GUniquePtr<SoupURI> soupURI = request.createSoupURI();
     if (!soupURI)
         return false;
 
index 679152b..45b1ce8 100644 (file)
@@ -27,8 +27,8 @@
 #ifndef ResourceRequest_h
 #define ResourceRequest_h
 
+#include "GUniquePtrSoup.h"
 #include "ResourceRequestBase.h"
-#include "SoupURIUtils.h"
 #include <libsoup/soup.h>
 
 namespace WebCore {
@@ -78,7 +78,7 @@ namespace WebCore {
         }
 
         ResourceRequest(SoupRequest* soupRequest)
-            : ResourceRequestBase(soupURIToKURL(soup_request_get_uri(soupRequest)), UseProtocolCachePolicy)
+            : ResourceRequestBase(URL(soup_request_get_uri(soupRequest)), UseProtocolCachePolicy)
             , m_acceptEncoding(true)
             , m_soupFlags(static_cast<SoupMessageFlags>(0))
             , m_initiatingPageID(0)
@@ -105,7 +105,7 @@ namespace WebCore {
         uint64_t initiatingPageID() const { return m_initiatingPageID; }
         void setInitiatingPageID(uint64_t pageID) { m_initiatingPageID = pageID; }
 
-        SoupURI* soupURI() const;
+        GUniquePtr<SoupURI> createSoupURI() const;
 
     private:
         friend class ResourceRequestBase;
index bf6c6f9..44d1392 100644 (file)
@@ -23,7 +23,6 @@
 #include "GUniquePtrSoup.h"
 #include "HTTPParsers.h"
 #include "MIMETypeRegistry.h"
-#include "SoupURIUtils.h"
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
 
@@ -33,11 +32,9 @@ void ResourceRequest::updateSoupMessageMembers(SoupMessage* soupMessage) const
 {
     updateSoupMessageHeaders(soupMessage->request_headers);
 
-    String firstPartyString = firstPartyForCookies().string();
-    if (!firstPartyString.isEmpty()) {
-        GUniquePtr<SoupURI> firstParty(soup_uri_new(firstPartyString.utf8().data()));
+    GUniquePtr<SoupURI> firstParty = firstPartyForCookies().createSoupURI();
+    if (firstParty)
         soup_message_set_first_party(soupMessage, firstParty.get());
-    }
 
     soup_message_set_flags(soupMessage, m_soupFlags);
 
@@ -70,7 +67,7 @@ void ResourceRequest::updateSoupMessage(SoupMessage* soupMessage) const
 {
     g_object_set(soupMessage, SOUP_MESSAGE_METHOD, httpMethod().utf8().data(), NULL);
 
-    GUniquePtr<SoupURI> uri(soupURI());
+    GUniquePtr<SoupURI> uri = createSoupURI();
     soup_message_set_uri(soupMessage, uri.get());
 
     updateSoupMessageMembers(soupMessage);
@@ -93,7 +90,7 @@ SoupMessage* ResourceRequest::toSoupMessage() const
 void ResourceRequest::updateFromSoupMessage(SoupMessage* soupMessage)
 {
     bool shouldPortBeResetToZero = m_url.hasPort() && !m_url.port();
-    m_url = soupURIToKURL(soup_message_get_uri(soupMessage));
+    m_url = URL(soup_message_get_uri(soupMessage));
 
     // SoupURI cannot differeniate between an explicitly specified port 0 and
     // no port specified.
@@ -107,9 +104,8 @@ void ResourceRequest::updateFromSoupMessage(SoupMessage* soupMessage)
     if (soupMessage->request_body->data)
         m_httpBody = FormData::create(soupMessage->request_body->data, soupMessage->request_body->length);
 
-    SoupURI* firstParty = soup_message_get_first_party(soupMessage);
-    if (firstParty)
-        m_firstPartyForCookies = soupURIToKURL(firstParty);
+    if (SoupURI* firstParty = soup_message_get_first_party(soupMessage))
+        m_firstPartyForCookies = URL(firstParty);
 
     m_soupFlags = soup_message_get_flags(soupMessage);
 
@@ -143,31 +139,11 @@ unsigned initializeMaximumHTTPConnectionCountPerHost()
     return 10000;
 }
 
-SoupURI* ResourceRequest::soupURI() const
+GUniquePtr<SoupURI> ResourceRequest::createSoupURI() const
 {
-    // WebKit does not support fragment identifiers in data URLs, but soup does.
-    // Before passing the URL to soup, we should make sure to urlencode any '#'
-    // characters, so that soup does not interpret them as fragment identifiers.
-    // See http://wkbug.com/68089
-    if (m_url.protocolIsData()) {
-        String urlString = m_url.string();
-        urlString.replace("#", "%23");
-        return soup_uri_new(urlString.utf8().data());
-    }
-
     URL url = m_url;
     url.removeFragmentIdentifier();
-    SoupURI* uri = soup_uri_new(url.string().utf8().data());
-
-    // Versions of libsoup prior to 2.42 have a soup_uri_new that will convert empty passwords that are not
-    // prefixed by a colon into null. Some parts of soup like the SoupAuthenticationManager will only be active
-    // when both the username and password are non-null. When we have credentials, empty usernames and passwords
-    // should be empty strings instead of null.
-    if (!url.user().isEmpty() || !url.pass().isEmpty()) {
-        soup_uri_set_user(uri, url.user().utf8().data());
-        soup_uri_set_password(uri, url.pass().utf8().data());
-    }
-    return uri;
+    return url.createSoupURI();
 }
 
 }
index e362f7b..c891c09 100644 (file)
@@ -23,7 +23,6 @@
 
 #include "HTTPParsers.h"
 #include "MIMETypeRegistry.h"
-#include "SoupURIUtils.h"
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
 #include <wtf/text/WTFString.h>
@@ -57,7 +56,7 @@ SoupMessage* ResourceResponse::toSoupMessage() const
 
 void ResourceResponse::updateFromSoupMessage(SoupMessage* soupMessage)
 {
-    m_url = soupURIToKURL(soup_message_get_uri(soupMessage));
+    m_url = URL(soup_message_get_uri(soupMessage));
 
     m_httpStatusCode = soupMessage->status_code;
     setHTTPStatusText(soupMessage->reason_phrase);
diff --git a/Source/WebCore/platform/network/soup/SoupURIUtils.cpp b/Source/WebCore/platform/network/soup/SoupURIUtils.cpp
deleted file mode 100644 (file)
index ea8902a..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *  Copyright (C) 20010 Igalia S.L.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "config.h"
-#include "SoupURIUtils.h"
-
-#include <libsoup/soup.h>
-#include <wtf/gobject/GUniquePtr.h>
-
-namespace WebCore {
-
-// Motivated by https://bugs.webkit.org/show_bug.cgi?id=38956. libsoup
-// does not add the password to the URL when calling
-// soup_uri_to_string, and thus the requests are not properly
-// built. Fixing soup_uri_to_string is a no-no as the maintainer does
-// not want to break compatibility with previous implementations
-URL soupURIToKURL(SoupURI* soupURI)
-{
-    GUniquePtr<gchar> urlString(soup_uri_to_string(soupURI, FALSE));
-    URL url(URL(), String::fromUTF8(urlString.get()));
-
-    if (!soupURI->password)
-        return url;
-
-    url.setPass(String::fromUTF8(soupURI->password));
-    return url;
-}
-
-}
diff --git a/Source/WebCore/platform/network/soup/SoupURIUtils.h b/Source/WebCore/platform/network/soup/SoupURIUtils.h
deleted file mode 100644 (file)
index 5f6e8d5..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2010 Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SoupURIUtils_h
-#define SoupURIUtils_h
-
-#include "URL.h"
-
-typedef struct _SoupURI SoupURI;
-
-namespace WebCore {
-URL soupURIToKURL(SoupURI* soupURI);
-}
-
-#endif
diff --git a/Source/WebCore/platform/soup/URLSoup.cpp b/Source/WebCore/platform/soup/URLSoup.cpp
new file mode 100644 (file)
index 0000000..be8e3f3
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "URL.h"
+
+#include <libsoup/soup.h>
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+URL::URL(SoupURI* soupURI)
+{
+    if (!soupURI) {
+        invalidate();
+        return;
+    }
+
+    GUniquePtr<gchar> urlString(soup_uri_to_string(soupURI, FALSE));
+    parse(String::fromUTF8(urlString.get()));
+    if (!isValid())
+        return;
+
+    // Motivated by https://bugs.webkit.org/show_bug.cgi?id=38956. libsoup
+    // does not add the password to the URL when calling
+    // soup_uri_to_string, and thus the requests are not properly
+    // built. Fixing soup_uri_to_string is a no-no as the maintainer does
+    // not want to break compatibility with previous implementations
+    if (soupURI->password)
+        setPass(String::fromUTF8(soupURI->password));
+}
+
+GUniquePtr<SoupURI> URL::createSoupURI() const
+{
+    if (!isValid())
+        return nullptr;
+
+    // WebKit does not support fragment identifiers in data URLs, but soup does.
+    // Before passing the URL to soup, we should make sure to urlencode any '#'
+    // characters, so that soup does not interpret them as fragment identifiers.
+    // See http://wkbug.com/68089
+    if (protocolIsData()) {
+        String urlString = string();
+        urlString.replace("#", "%23");
+        return GUniquePtr<SoupURI>(soup_uri_new(urlString.utf8().data()));
+    }
+
+    GUniquePtr<SoupURI> soupURI(soup_uri_new(string().utf8().data()));
+
+    // Versions of libsoup prior to 2.42 have a soup_uri_new that will convert empty passwords that are not
+    // prefixed by a colon into null. Some parts of soup like the SoupAuthenticationManager will only be active
+    // when both the username and password are non-null. When we have credentials, empty usernames and passwords
+    // should be empty strings instead of null.
+    String urlUser = user();
+    String urlPass = pass();
+    if (!urlUser.isEmpty() || !urlPass.isEmpty()) {
+        soup_uri_set_user(soupURI.get(), urlUser.utf8().data());
+        soup_uri_set_password(soupURI.get(), urlPass.utf8().data());
+    }
+
+    return soupURI;
+}
+
+} // namespace WebCore
index 84d813e..bcf1ac1 100644 (file)
@@ -1,3 +1,16 @@
+2014-01-28  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [SOUP] Remove soupURIToKURL
+        https://bugs.webkit.org/show_bug.cgi?id=127104
+
+        Reviewed by Martin Robinson.
+
+        * TestWebKitAPI/GNUmakefile.am: Add soup cppflags to WebCore unit
+        tests, because URL.h now includes GUniquePtrSoup.h.
+        * TestWebKitAPI/CMakeLists.txt: Ditto.
+        * WebKitTestRunner/PlatformEfl.cmake: Add soup cppflags to WTR,
+        because URL.h now includes GUniquePtrSoup.h.
+
 2014-01-27  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Make webkit_uri_scheme_request_get_web_view() work with CustomProtocols
index 2b7eae1..9ed4884 100644 (file)
@@ -15,6 +15,7 @@ include_directories(${CMAKE_BINARY_DIR}
     ${WEBCORE_DIR}/platform/graphics
     ${WEBCORE_DIR}/platform/text
     ${WEBCORE_DIR}/platform/network
+    ${WEBCORE_DIR}/platform/network/soup
     ${WEBKIT2_DIR}/Platform/IPC
     ${WEBKIT2_DIR}/Shared
     ${WEBKIT2_DIR}/Shared/API/c
index 3d30c2a..cc415a3 100644 (file)
@@ -284,7 +284,9 @@ DISTCLEANFILES += \
 
 Programs_TestWebKitAPI_WebCore_TestWebCore_CPPFLAGS = \
        $(Libraries_libTestWebKitAPIMain_la_CPPFLAGS) \
-       -I$(top_builddir)/DerivedSources/WebCore/include
+       -I$(srcdir)/Source/WebCore/platform/network/soup \
+       -I$(top_builddir)/DerivedSources/WebCore/include \
+       $(LIBSOUP_CFLAGS)
 
 Programs_TestWebKitAPI_WebCore_TestWebCore_CXXFLAGS = \
        -DGTEST_HAS_RTTI=0 \
index fbaafde..b6f1dfc 100644 (file)
@@ -23,6 +23,7 @@ list(APPEND WebKitTestRunner_INCLUDE_DIRECTORIES
     ${TOOLS_DIR}/DumpRenderTree/efl/
     ${WEBKIT2_DIR}/UIProcess/API/efl
     "${WTF_DIR}/wtf/gobject"
+    ${WEBCORE_DIR}/platform/network/soup
     ${CAIRO_INCLUDE_DIRS}
     ${ECORE_EVAS_INCLUDE_DIRS}
     ${ECORE_FILE_INCLUDE_DIRS}