Summary: | should not pass URI fragments to libsoup | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Dan Winship <danw> | ||||
Component: | WebKitGTK | Assignee: | Nobody <webkit-unassigned> | ||||
Status: | RESOLVED FIXED | ||||||
Severity: | Normal | CC: | gustavo, xan.lopez | ||||
Priority: | P2 | ||||||
Version: | 528+ (Nightly build) | ||||||
Hardware: | PC | ||||||
OS: | Linux | ||||||
Attachments: |
|
Description
Dan Winship
2009-08-24 14:49:59 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). You probably want to operate on the parsed URL, not the string form. In ResourceHandle::start(), you have: KURL url = request().url(); String urlString = url.string(); and you could just add a call to url.removeFragmentIdentifier() in between. Likewise in updateFromSoupMessage. (Though I'm not sure if you want m_url to contain the fragment or not.) Created attachment 39187 [details]
dontpassfragment.patch
Don't pass fragments in URIs to libsoup.
Comment on attachment 39187 [details]
dontpassfragment.patch
Looks good, thanks!
|