Don't prefetch IP addresses and bail out if the soup URI is invalid
This commit is contained in:
parent
8a62c9ee7a
commit
e4f163447c
1 changed files with 23 additions and 7 deletions
|
@ -22,17 +22,33 @@ static int host_count;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dnsprefetch_do_prefetch (WebKitWebView* web_view,
|
dnsprefetch_do_prefetch (WebKitWebView* web_view,
|
||||||
gchar *title,
|
const gchar* title,
|
||||||
gchar *uri,
|
const char* uri,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
SoupURI* s_uri;
|
SoupURI* s_uri;
|
||||||
|
|
||||||
/* FIXME: Ignore IP addresses */
|
if (!uri)
|
||||||
if (!(uri && g_str_has_prefix (uri, "http")))
|
return;
|
||||||
|
s_uri = soup_uri_new (uri);
|
||||||
|
if (!s_uri)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s_uri = soup_uri_new (uri);
|
#if GLIB_CHECK_VERSION (2, 22, 0)
|
||||||
|
if (g_hostname_is_ip_address (s_uri->host))
|
||||||
|
#else
|
||||||
|
if (g_ascii_isdigit (s_uri->host[0]) && g_strstr_len (s_uri->host, 4, "."))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
soup_uri_free (s_uri);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!g_str_has_prefix (uri, "http"))
|
||||||
|
{
|
||||||
|
soup_uri_free (s_uri);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!g_regex_match_simple (s_uri->host, hosts,
|
if (!g_regex_match_simple (s_uri->host, hosts,
|
||||||
G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY))
|
G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue