[glib: 9/13] gio: use g_uri_split_with_user() in save_userinfo()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 9/13] gio: use g_uri_split_with_user() in save_userinfo()
- Date: Wed, 5 Aug 2020 16:06:03 +0000 (UTC)
commit 1b6a0535e8e3aad12febaa686dd53b867d86494e
Author: Marc-André Lureau <marcandre lureau redhat com>
Date: Tue Jul 7 13:02:50 2020 +0400
gio: use g_uri_split_with_user() in save_userinfo()
Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>
gio/gproxyaddressenumerator.c | 37 ++++++-------------------------------
1 file changed, 6 insertions(+), 31 deletions(-)
---
diff --git a/gio/gproxyaddressenumerator.c b/gio/gproxyaddressenumerator.c
index ecf04d110..d3de4940c 100644
--- a/gio/gproxyaddressenumerator.c
+++ b/gio/gproxyaddressenumerator.c
@@ -93,39 +93,14 @@ G_DEFINE_TYPE_WITH_PRIVATE (GProxyAddressEnumerator, g_proxy_address_enumerator,
static void
save_userinfo (GProxyAddressEnumeratorPrivate *priv,
- const gchar *proxy)
+ const gchar *proxy)
{
- gchar *userinfo;
+ g_clear_pointer (&priv->proxy_username, g_free);
+ g_clear_pointer (&priv->proxy_password, g_free);
- if (priv->proxy_username)
- {
- g_free (priv->proxy_username);
- priv->proxy_username = NULL;
- }
-
- if (priv->proxy_password)
- {
- g_free (priv->proxy_password);
- priv->proxy_password = NULL;
- }
-
- if (_g_uri_parse_authority (proxy, NULL, NULL, &userinfo, NULL))
- {
- if (userinfo)
- {
- gchar **split = g_strsplit (userinfo, ":", 2);
-
- if (split[0] != NULL)
- {
- priv->proxy_username = g_uri_unescape_string (split[0], NULL);
- if (split[1] != NULL)
- priv->proxy_password = g_uri_unescape_string (split[1], NULL);
- }
-
- g_strfreev (split);
- g_free (userinfo);
- }
- }
+ g_uri_split_with_user (proxy, G_URI_FLAGS_HAS_PASSWORD, NULL,
+ &priv->proxy_username, &priv->proxy_password,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]