[evolution-data-server] I#247 - Trust Prompt: Can fail to extract host from a collection account



commit ae580dccc62b325689f226a8228cedf58b801871
Author: Milan Crha <mcrha redhat com>
Date:   Fri Sep 11 08:32:52 2020 +0200

    I#247 - Trust Prompt: Can fail to extract host from a collection account
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/247

 src/libedataserverui/e-trust-prompt.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/libedataserverui/e-trust-prompt.c b/src/libedataserverui/e-trust-prompt.c
index e2423c935..0e4ce26ad 100644
--- a/src/libedataserverui/e-trust-prompt.c
+++ b/src/libedataserverui/e-trust-prompt.c
@@ -578,8 +578,7 @@ e_trust_prompt_run_for_source (GtkWindow *parent,
                host = NULL;
 
        if (!host || !*host) {
-               g_free (host);
-               host = NULL;
+               g_clear_pointer (&host, g_free);
 
                if (e_source_has_extension (source, E_SOURCE_EXTENSION_GOA)) {
                        ESourceGoa *goa_extension;
@@ -599,6 +598,30 @@ e_trust_prompt_run_for_source (GtkWindow *parent,
                }
        }
 
+       if ((!host || !*host) && e_source_has_extension (source, E_SOURCE_EXTENSION_COLLECTION)) {
+               ESourceCollection *collection_extension;
+               gchar *url;
+
+               g_clear_pointer (&host, g_free);
+
+               collection_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_COLLECTION);
+
+               url = e_source_collection_dup_calendar_url (collection_extension);
+               host = trust_prompt_get_host_from_url (url);
+               g_free (url);
+
+               if (!host) {
+                       url = e_source_collection_dup_contacts_url (collection_extension);
+                       host = trust_prompt_get_host_from_url (url);
+                       g_free (url);
+               }
+       }
+
+       /* The worst case, failed to extract host from the ESource, but it's a mandatory argument,
+          thus fallback to the source's display name, instead of the real host name. */
+       if (!host)
+               host = e_source_dup_display_name (source);
+
        certificate = g_tls_certificate_new_from_pem (certificate_pem, -1, &save_data->error);
        if (certificate) {
                const gchar *source_extension = NULL;


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