[Webkit-unassigned] [Bug 28687] should not pass URI fragments to libsoup

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Aug 26 03:59:27 PDT 2009


https://bugs.webkit.org/show_bug.cgi?id=28687


Xan Lopez <xan.lopez at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xan.lopez at gmail.com




--- Comment #1 from Xan Lopez <xan.lopez at gmail.com>  2009-08-26 03:59:27 PDT ---
So, I've tried something like...

diff --git a/WebCore/platform/network/soup/ResourceRequestSoup.cpp
b/WebCore/platform/network/soup/ResourceRequestSoup.cpp
index f2011bb..eec75e0 100644
--- a/WebCore/platform/network/soup/ResourceRequestSoup.cpp
+++ b/WebCore/platform/network/soup/ResourceRequestSoup.cpp
@@ -30,9 +30,20 @@ using namespace std;

 namespace WebCore {

+static char* stripFragmentFromURI(char* uri)
+{
+    char* ptr = g_strrstr(uri, "#");
+    if (ptr && *(ptr-1) != '&')
+        *ptr = '\0';
+
+    return uri;
+}
+
 SoupMessage* ResourceRequest::toSoupMessage() const
 {
-    SoupMessage* soupMessage = soup_message_new(httpMethod().utf8().data(),
url().string().utf8().data());
+    GOwnPtr<char>
uri(stripFragmentFromURI(g_strdup(url().string().utf8().data())));
+    SoupMessage* soupMessage = soup_message_new(httpMethod().utf8().data(),
+                                                const_cast<char*>(uri.get()));
     if (!soupMessage)
         return 0;

@@ -53,7 +64,7 @@ SoupMessage* ResourceRequest::toSoupMessage() const
 void ResourceRequest::updateFromSoupMessage(SoupMessage* soupMessage)
 {
     SoupURI* soupURI = soup_message_get_uri(soupMessage);
-    GOwnPtr<gchar> uri(soup_uri_to_string(soupURI, FALSE));
+    GOwnPtr<gchar> uri(stripFragmentFromURI(soup_uri_to_string(soupURI,
FALSE)));
     m_url = KURL(KURL(), String::fromUTF8(uri.get()));

And all the http tests seem to still pass. Looks reasonable Dan? I first didn't
check that the previous character is a & and failed one test that dealt with
espaced hex stuff in the URL. Is there any function in soup/glib I should be
using to strip the fragment from a string? (Other than going through SoupURI
somehow, I suppose).

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list