[evolution-data-server/gnome-42] I#392 - Sanitize IPv6 proxy address before passing it to WebKitGTK



commit bffff9b74991fa982b81eaccc0c9bca3809023e7
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jun 6 12:27:30 2022 +0200

    I#392 - Sanitize IPv6 proxy address before passing it to WebKitGTK
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/392

 .../e-credentials-prompter-impl-oauth2.c           | 24 +++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/src/libedataserverui/e-credentials-prompter-impl-oauth2.c 
b/src/libedataserverui/e-credentials-prompter-impl-oauth2.c
index 6f1ccb51c..1756a2802 100644
--- a/src/libedataserverui/e-credentials-prompter-impl-oauth2.c
+++ b/src/libedataserverui/e-credentials-prompter-impl-oauth2.c
@@ -561,6 +561,24 @@ credentials_prompter_impl_oauth2_get_prompt_strings (ESourceRegistry *registry,
        g_free (display_name);
 }
 
+static gchar *
+credentials_prompter_impl_oauth2_sanitize_host (gchar *host)
+{
+       if (!host || !*host)
+               return host;
+
+       if (*host == '[' && strchr (host, ':')) {
+               gint len = strlen (host);
+
+               if (len > 2 && host[len - 1] == ']') {
+                       memmove (host, host + 1, len - 2);
+                       host[len - 2] = '\0';
+               }
+       }
+
+       return host;
+}
+
 static void
 credentials_prompter_impl_oauth2_set_proxy (WebKitWebContext *web_context,
                                            ESourceRegistry *registry,
@@ -604,7 +622,7 @@ credentials_prompter_impl_oauth2_set_proxy (WebKitWebContext *web_context,
                case E_PROXY_METHOD_MANUAL:
                        ignore_hosts = e_source_proxy_dup_ignore_hosts (proxy);
 
-                       tmp = e_source_proxy_dup_socks_host (proxy);
+                       tmp = credentials_prompter_impl_oauth2_sanitize_host (e_source_proxy_dup_socks_host 
(proxy));
                        if (tmp && *tmp) {
                                suri = soup_uri_new (NULL);
                                soup_uri_set_scheme (suri, "socks");
@@ -623,7 +641,7 @@ credentials_prompter_impl_oauth2_set_proxy (WebKitWebContext *web_context,
                        }
                        g_free (tmp);
 
-                       tmp = e_source_proxy_dup_http_host (proxy);
+                       tmp = credentials_prompter_impl_oauth2_sanitize_host (e_source_proxy_dup_http_host 
(proxy));
                        if (tmp && *tmp) {
                                suri = soup_uri_new (NULL);
                                soup_uri_set_scheme (suri, SOUP_URI_SCHEME_HTTP);
@@ -650,7 +668,7 @@ credentials_prompter_impl_oauth2_set_proxy (WebKitWebContext *web_context,
                        }
                        g_free (tmp);
 
-                       tmp = e_source_proxy_dup_https_host (proxy);
+                       tmp = credentials_prompter_impl_oauth2_sanitize_host (e_source_proxy_dup_https_host 
(proxy));
                        if (tmp && *tmp) {
                                suri = soup_uri_new (NULL);
                                soup_uri_set_scheme (suri, SOUP_URI_SCHEME_HTTP);


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