Commit 5f2c20e8 authored by Bastien Nocera's avatar Bastien Nocera Committed by Philip Withnall

networkaddress: Return an error from _g_uri_parse_authority()

So that errors can be propagated if necessary.

https://bugzilla.gnome.org/show_bug.cgi?id=772989
parent 88366621
......@@ -489,7 +489,8 @@ gboolean
_g_uri_parse_authority (const char *uri,
char **host,
guint16 *port,
char **userinfo)
char **userinfo,
GError **error)
{
char *tmp_str;
const char *start, *p, *at, *delim;
......@@ -517,7 +518,7 @@ _g_uri_parse_authority (const char *uri,
tmp_str = g_uri_parse_scheme (uri);
if (tmp_str == NULL)
return FALSE;
goto error;
g_free (tmp_str);
......@@ -528,7 +529,7 @@ _g_uri_parse_authority (const char *uri,
start = strstr (p, "//");
if (start == NULL)
return FALSE;
goto error;
start += 2;
......@@ -559,7 +560,7 @@ _g_uri_parse_authority (const char *uri,
{
if (!(g_ascii_isxdigit (p[0]) ||
g_ascii_isxdigit (p[1])))
return FALSE;
goto error;
p++;
......@@ -571,7 +572,7 @@ _g_uri_parse_authority (const char *uri,
strchr (G_URI_OTHER_UNRESERVED, c) ||
strchr (G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS, c) ||
c == ':'))
return FALSE;
goto error;
}
if (userinfo)
......@@ -618,7 +619,7 @@ _g_uri_parse_authority (const char *uri,
strchr (G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS, c) ||
c == ':' ||
c == '.'))
goto error;
goto error;
}
if (host)
......@@ -649,7 +650,7 @@ _g_uri_parse_authority (const char *uri,
{
if (!(g_ascii_isxdigit (p[0]) ||
g_ascii_isxdigit (p[1])))
goto error;
goto error;
p++;
......@@ -660,7 +661,7 @@ _g_uri_parse_authority (const char *uri,
if (!(g_ascii_isalnum (c) ||
strchr (G_URI_OTHER_UNRESERVED, c) ||
strchr (G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS, c)))
goto error;
goto error;
}
if (host)
......@@ -685,7 +686,7 @@ _g_uri_parse_authority (const char *uri,
break;
if (!g_ascii_isdigit (c))
goto error;
goto error;
tmp = (tmp * 10) + (c - '0');
......@@ -699,6 +700,9 @@ _g_uri_parse_authority (const char *uri,
return TRUE;
error:
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
"Invalid URI ‘%s’", uri);
if (host && *host)
{
g_free (*host);
......@@ -782,13 +786,8 @@ g_network_address_parse_uri (const gchar *uri,
gchar *hostname;
guint16 port;
if (!_g_uri_parse_authority (uri, &hostname, &port, NULL))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
"Invalid URI '%s'",
uri);
return NULL;
}
if (!_g_uri_parse_authority (uri, &hostname, &port, NULL, error))
return NULL;
if (port == 0)
port = default_port;
......
......@@ -26,7 +26,8 @@ G_BEGIN_DECLS
gboolean _g_uri_parse_authority (const char *uri,
char **host,
guint16 *port,
char **userinfo);
char **userinfo,
GError **error);
gchar * _g_uri_from_authority (const gchar *protocol,
const gchar *host,
guint port,
......
......@@ -93,7 +93,7 @@ save_userinfo (GProxyAddressEnumeratorPrivate *priv,
priv->proxy_password = NULL;
}
if (_g_uri_parse_authority (proxy, NULL, NULL, &userinfo))
if (_g_uri_parse_authority (proxy, NULL, NULL, &userinfo, NULL))
{
if (userinfo)
{
......
......@@ -329,7 +329,7 @@ g_simple_proxy_resolver_lookup (GProxyResolver *proxy_resolver,
gchar *host = NULL;
gushort port;
if (_g_uri_parse_authority (uri, &host, &port, NULL) &&
if (_g_uri_parse_authority (uri, &host, &port, NULL, NULL) &&
ignore_host (resolver, host, port))
proxy = "direct://";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment