mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
gio: use g_uri_split_network() in g_network_address_parse_uri()
_g_uri_parse_authority() can be replaced with g_uri_split_network() & PARSE_STRICT. Keep the original error code, for compatibility reasons. Notice that GUri uses gint for the port, and value -1 if the port value is missing. However, GNetworkAddress::port is a guint. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
a173a6f617
commit
6f419e7e2f
@ -787,25 +787,27 @@ g_network_address_parse_uri (const gchar *uri,
|
|||||||
guint16 default_port,
|
guint16 default_port,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GSocketConnectable *conn;
|
GSocketConnectable *conn = NULL;
|
||||||
gchar *scheme;
|
gchar *scheme = NULL;
|
||||||
gchar *hostname;
|
gchar *hostname = NULL;
|
||||||
guint16 port;
|
gint port;
|
||||||
|
|
||||||
if (!_g_uri_parse_authority (uri, &hostname, &port, NULL, error))
|
if (!g_uri_split_network (uri, G_URI_FLAGS_PARSE_STRICT,
|
||||||
return NULL;
|
&scheme, &hostname, &port, NULL))
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
|
||||||
|
"Invalid URI ‘%s’", uri);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (port == 0)
|
if (port <= 0)
|
||||||
port = default_port;
|
port = default_port;
|
||||||
|
|
||||||
scheme = g_uri_parse_scheme (uri);
|
|
||||||
|
|
||||||
conn = g_object_new (G_TYPE_NETWORK_ADDRESS,
|
conn = g_object_new (G_TYPE_NETWORK_ADDRESS,
|
||||||
"hostname", hostname,
|
"hostname", hostname,
|
||||||
"port", port,
|
"port", (guint) port,
|
||||||
"scheme", scheme,
|
"scheme", scheme,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_free (scheme);
|
g_free (scheme);
|
||||||
g_free (hostname);
|
g_free (hostname);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user