[glib: 7/13] gio: use g_uri_is_valid()




commit a173a6f617d8bc058fb60f13eff08ed68c663926
Author: Marc-André Lureau <marcandre lureau redhat com>
Date:   Mon Jul 6 23:45:01 2020 +0400

    gio: use g_uri_is_valid()
    
    _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 <marcandre lureau redhat com>

 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));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]