From a173a6f617d8bc058fb60f13eff08ed68c663926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 6 Jul 2020 23:45:01 +0400 Subject: [PATCH] gio: use g_uri_is_valid() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _g_uri_parse_authority() without argument is actually checking that the URI is valid, by checking it parses successfully We keep the existing error domain / code for compatibility reasons, instead of raising the underlying G_URI_ERROR. Signed-off-by: Marc-André Lureau --- gio/gproxyresolver.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gio/gproxyresolver.c b/gio/gproxyresolver.c index bd9528dd0..f72ad2a72 100644 --- a/gio/gproxyresolver.c +++ b/gio/gproxyresolver.c @@ -29,6 +29,7 @@ #include "gcancellable.h" #include "gtask.h" #include "giomodule.h" +#include "gioerror.h" #include "giomodule-priv.h" #include "gnetworkingprivate.h" @@ -147,8 +148,12 @@ g_proxy_resolver_lookup (GProxyResolver *resolver, g_return_val_if_fail (G_IS_PROXY_RESOLVER (resolver), NULL); g_return_val_if_fail (uri != NULL, NULL); - if (!_g_uri_parse_authority (uri, NULL, NULL, NULL, error)) - return NULL; + if (!g_uri_is_valid (uri, G_URI_FLAGS_PARSE_STRICT, NULL)) + { + g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, + "Invalid URI ‘%s’", uri); + return NULL; + } iface = G_PROXY_RESOLVER_GET_IFACE (resolver); @@ -181,8 +186,10 @@ g_proxy_resolver_lookup_async (GProxyResolver *resolver, g_return_if_fail (G_IS_PROXY_RESOLVER (resolver)); g_return_if_fail (uri != NULL); - if (!_g_uri_parse_authority (uri, NULL, NULL, NULL, &error)) + if (!g_uri_is_valid (uri, G_URI_FLAGS_PARSE_STRICT, NULL)) { + g_set_error (&error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, + "Invalid URI ‘%s’", uri); g_task_report_error (resolver, callback, user_data, g_proxy_resolver_lookup_async, g_steal_pointer (&error));