From a4a516a8ab22f6c0c4f4f4c8d7464bd2cb59c5e5 Mon Sep 17 00:00:00 2001 From: Gustav Johansson Date: Wed, 21 Aug 2024 10:33:38 +0200 Subject: [PATCH] simpleproxyresolver: Ignore host with scope id Ignore host successfully when a ipv6 address contains a scope id. --- gio/gsimpleproxyresolver.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gio/gsimpleproxyresolver.c b/gio/gsimpleproxyresolver.c index 41136527f..53fdd1346 100644 --- a/gio/gsimpleproxyresolver.c +++ b/gio/gsimpleproxyresolver.c @@ -26,6 +26,7 @@ #include "gsimpleproxyresolver.h" #include "ginetaddress.h" +#include "ginetsocketaddress.h" #include "ginetaddressmask.h" #include "gnetworkingprivate.h" #include "gtask.h" @@ -264,9 +265,13 @@ ignore_host (GSimpleProxyResolver *resolver, if (priv->ignore_ips) { GInetAddress *iaddr; + GInetSocketAddress *isaddr = NULL; - iaddr = g_inet_address_new_from_string (host); - if (iaddr) + /* Grab the GInetAddress from the GInetSocketAddress in order to support + * scope ID. */ + isaddr = (GInetSocketAddress *) g_inet_socket_address_new_from_string (host, 0); + iaddr = (isaddr != NULL) ? g_inet_socket_address_get_address (isaddr) : NULL; + if (iaddr != NULL) { for (i = 0; i < priv->ignore_ips->len; i++) { @@ -278,11 +283,12 @@ ignore_host (GSimpleProxyResolver *resolver, break; } } - - g_object_unref (iaddr); - if (ignore) - return TRUE; } + + g_clear_object (&isaddr); + + if (ignore) + return TRUE; } if (priv->ignore_domains)