Only strip referrer from valid Soup URI

Fixes: https://bugs.launchpad.net/midori/+bug/909415
This commit is contained in:
Christian Dywan 2012-01-03 23:47:11 +01:00
parent 5396456ec2
commit 57b093293a

View file

@ -958,19 +958,22 @@ midori_soup_session_settings_accept_language_cb (SoupSession* session,
if (referer && destination && !strstr (referer, destination->host)) if (referer && destination && !strstr (referer, destination->host))
{ {
SoupURI* stripped_uri = soup_uri_new (referer); SoupURI* stripped_uri = soup_uri_new (referer);
if (stripped_uri != NULL)
{
gchar* stripped_referer; gchar* stripped_referer;
soup_uri_set_path (stripped_uri, NULL); soup_uri_set_path (stripped_uri, NULL);
soup_uri_set_query (stripped_uri, NULL); soup_uri_set_query (stripped_uri, NULL);
stripped_referer = soup_uri_to_string (stripped_uri, FALSE); stripped_referer = soup_uri_to_string (stripped_uri, FALSE);
soup_uri_free (stripped_uri); soup_uri_free (stripped_uri);
if (g_getenv ("MIDORI_SOUP_DEBUG")) if (g_getenv ("MIDORI_SOUP_DEBUG"))
g_message ("Referer stripped"); g_message ("Referer %s stripped to %s", referer, stripped_referer);
soup_message_headers_replace (msg->request_headers, "Referer", soup_message_headers_replace (msg->request_headers, "Referer",
stripped_referer); stripped_referer);
g_free (stripped_referer); g_free (stripped_referer);
} }
} }
} }
}
static void static void
midori_soup_session_debug (SoupSession* session) midori_soup_session_debug (SoupSession* session)