Title: [162922] trunk
Revision
162922
Author
carlo...@webkit.org
Date
2014-01-28 01:08:40 -0800 (Tue, 28 Jan 2014)

Log Message

[SOUP] Remove soupURIToKURL
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.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (162921 => 162922)


--- trunk/Source/WebCore/ChangeLog	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Source/WebCore/ChangeLog	2014-01-28 09:08:40 UTC (rev 162922)
@@ -1,3 +1,45 @@
+2014-01-28  Carlos Garcia Campos  <cgar...@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  <cgar...@igalia.com>
 
         [GTK] Avoid unnecessary string duplications in FileSystemGtk

Modified: trunk/Source/WebCore/GNUmakefile.list.am (162921 => 162922)


--- trunk/Source/WebCore/GNUmakefile.list.am	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2014-01-28 09:08:40 UTC (rev 162922)
@@ -5866,8 +5866,6 @@
 	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 @@
 	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 \

Modified: trunk/Source/WebCore/PlatformEfl.cmake (162921 => 162922)


--- trunk/Source/WebCore/PlatformEfl.cmake	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Source/WebCore/PlatformEfl.cmake	2014-01-28 09:08:40 UTC (rev 162922)
@@ -167,13 +167,13 @@
     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
 

Modified: trunk/Source/WebCore/PlatformGTK.cmake (162921 => 162922)


--- trunk/Source/WebCore/PlatformGTK.cmake	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Source/WebCore/PlatformGTK.cmake	2014-01-28 09:08:40 UTC (rev 162922)
@@ -125,10 +125,10 @@
     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

Modified: trunk/Source/WebCore/platform/URL.h (162921 => 162922)


--- trunk/Source/WebCore/platform/URL.h	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Source/WebCore/platform/URL.h	2014-01-28 09:08:40 UTC (rev 162922)
@@ -35,6 +35,10 @@
 typedef const struct __CFURL* CFURLRef;
 #endif
 
+#if USE(SOUP)
+#include "GUniquePtrSoup.h"
+#endif
+
 #if PLATFORM(MAC)
 OBJC_CLASS NSURL;
 #endif
@@ -160,6 +164,11 @@
     RetainPtr<CFURLRef> createCFURL() const;
 #endif
 
+#if USE(SOUP)
+    URL(SoupURI*);
+    GUniquePtr<SoupURI> createSoupURI() const;
+#endif
+
 #if PLATFORM(MAC)
     URL(NSURL*);
     operator NSURL*() const;

Modified: trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp (162921 => 162922)


--- trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp	2014-01-28 09:08:40 UTC (rev 162922)
@@ -88,8 +88,8 @@
     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 @@
     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 @@
     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 @@
     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;

Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (162921 => 162922)


--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2014-01-28 09:08:40 UTC (rev 162922)
@@ -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 @@
     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 @@
 
     GOwnPtr<GError> error;
 
-    GUniquePtr<SoupURI> soupURI(request.soupURI());
+    GUniquePtr<SoupURI> soupURI = request.createSoupURI();
     if (!soupURI)
         return false;
 

Modified: trunk/Source/WebCore/platform/network/soup/ResourceRequest.h (162921 => 162922)


--- trunk/Source/WebCore/platform/network/soup/ResourceRequest.h	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Source/WebCore/platform/network/soup/ResourceRequest.h	2014-01-28 09:08:40 UTC (rev 162922)
@@ -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 @@
         }
 
         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 @@
         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;

Modified: trunk/Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp (162921 => 162922)


--- trunk/Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Source/WebCore/platform/network/soup/ResourceRequestSoup.cpp	2014-01-28 09:08:40 UTC (rev 162922)
@@ -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 @@
 {
     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 @@
 {
     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 @@
 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 @@
     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 @@
     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 = ""
     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();
 }
 
 }

Modified: trunk/Source/WebCore/platform/network/soup/ResourceResponseSoup.cpp (162921 => 162922)


--- trunk/Source/WebCore/platform/network/soup/ResourceResponseSoup.cpp	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Source/WebCore/platform/network/soup/ResourceResponseSoup.cpp	2014-01-28 09:08:40 UTC (rev 162922)
@@ -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 @@
 
 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);

Deleted: trunk/Source/WebCore/platform/network/soup/SoupURIUtils.cpp (162921 => 162922)


--- trunk/Source/WebCore/platform/network/soup/SoupURIUtils.cpp	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Source/WebCore/platform/network/soup/SoupURIUtils.cpp	2014-01-28 09:08:40 UTC (rev 162922)
@@ -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;
-}
-
-}

Deleted: trunk/Source/WebCore/platform/network/soup/SoupURIUtils.h (162921 => 162922)


--- trunk/Source/WebCore/platform/network/soup/SoupURIUtils.h	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Source/WebCore/platform/network/soup/SoupURIUtils.h	2014-01-28 09:08:40 UTC (rev 162922)
@@ -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

Added: trunk/Source/WebCore/platform/soup/URLSoup.cpp (0 => 162922)


--- trunk/Source/WebCore/platform/soup/URLSoup.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/soup/URLSoup.cpp	2014-01-28 09:08:40 UTC (rev 162922)
@@ -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

Modified: trunk/Tools/ChangeLog (162921 => 162922)


--- trunk/Tools/ChangeLog	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Tools/ChangeLog	2014-01-28 09:08:40 UTC (rev 162922)
@@ -1,3 +1,16 @@
+2014-01-28  Carlos Garcia Campos  <cgar...@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  <cgar...@igalia.com>
 
         [GTK] Make webkit_uri_scheme_request_get_web_view() work with CustomProtocols

Modified: trunk/Tools/TestWebKitAPI/CMakeLists.txt (162921 => 162922)


--- trunk/Tools/TestWebKitAPI/CMakeLists.txt	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Tools/TestWebKitAPI/CMakeLists.txt	2014-01-28 09:08:40 UTC (rev 162922)
@@ -15,6 +15,7 @@
     ${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

Modified: trunk/Tools/TestWebKitAPI/GNUmakefile.am (162921 => 162922)


--- trunk/Tools/TestWebKitAPI/GNUmakefile.am	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Tools/TestWebKitAPI/GNUmakefile.am	2014-01-28 09:08:40 UTC (rev 162922)
@@ -284,7 +284,9 @@
 
 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 \

Modified: trunk/Tools/WebKitTestRunner/PlatformEfl.cmake (162921 => 162922)


--- trunk/Tools/WebKitTestRunner/PlatformEfl.cmake	2014-01-28 08:15:39 UTC (rev 162921)
+++ trunk/Tools/WebKitTestRunner/PlatformEfl.cmake	2014-01-28 09:08:40 UTC (rev 162922)
@@ -23,6 +23,7 @@
     ${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}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to