typedef struct {
gchar *name;
- gint length;
+ gsize length;
gushort port;
} GSimpleProxyResolverDomain;
GSimpleProxyResolverPrivate *priv = resolver->priv;
gchar *ascii_host = NULL;
gboolean ignore = FALSE;
- gint i, length, offset;
+ gsize offset, length;
+ guint i;
if (priv->ignore_ips)
{
if (priv->ignore_domains)
{
+ length = 0;
if (g_hostname_is_non_ascii (host))
host = ascii_host = g_hostname_to_ascii (host);
- length = strlen (host);
+ if (host)
+ length = strlen (host);
- for (i = 0; priv->ignore_domains[i].length; i++)
+ for (i = 0; length > 0 && priv->ignore_domains[i].length; i++)
{
GSimpleProxyResolverDomain *domain = &priv->ignore_domains[i];
+ if (domain->length > length)
+ continue;
+
offset = length - domain->length;
if ((domain->port == 0 || domain->port == port) &&
(offset == 0 || (offset > 0 && host[offset - 1] == '.')) &&
if (priv->ignore_ips || priv->ignore_domains)
{
gchar *host = NULL;
- gushort port;
+ gint port;
- if (_g_uri_parse_authority (uri, &host, &port, NULL) &&
- ignore_host (resolver, host, port))
+ if (g_uri_split_network (uri, G_URI_FLAGS_NONE, NULL,
+ &host, &port, NULL) &&
+ ignore_host (resolver, host, port > 0 ? port : 0))
proxy = "direct://";
g_free (host);
* g_simple_proxy_resolver_new:
* @default_proxy: (nullable): the default proxy to use, eg
* "socks://192.168.1.1"
- * @ignore_hosts: (nullable): an optional list of hosts/IP addresses
+ * @ignore_hosts: (array zero-terminated=1) (nullable): an optional list of hosts/IP addresses
* to not use a proxy for.
*
* Creates a new #GSimpleProxyResolver. See
/**
* g_simple_proxy_resolver_set_ignore_hosts:
* @resolver: a #GSimpleProxyResolver
- * @ignore_hosts: %NULL-terminated list of hosts/IP addresses
+ * @ignore_hosts: (array zero-terminated=1): %NULL-terminated list of hosts/IP addresses
* to not use a proxy for
*
* Sets the list of ignored hosts.