[evolution-mapi] Bug #576738 - Crash on Authenticate with backslash in user name
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Bug #576738 - Crash on Authenticate with backslash in user name
- Date: Tue, 23 Feb 2010 17:04:11 +0000 (UTC)
commit a1f0d06c617d701b1449efe1dba3b9eab36511fa
Author: Milan Crha <mcrha redhat com>
Date: Tue Feb 23 18:01:10 2010 +0100
Bug #576738 - Crash on Authenticate with backslash in user name
.../exchange-mapi-account-listener.c | 4 ++--
.../exchange-mapi-account-setup.c | 13 ++++++++++++-
src/libexchangemapi/exchange-mapi-connection.c | 2 +-
src/libexchangemapi/exchange-mapi-utils.c | 17 +++++++++++++++++
src/libexchangemapi/exchange-mapi-utils.h | 2 ++
5 files changed, 34 insertions(+), 4 deletions(-)
---
diff --git a/src/account-setup-eplugin/exchange-mapi-account-listener.c b/src/account-setup-eplugin/exchange-mapi-account-listener.c
index badcf07..b243570 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-listener.c
+++ b/src/account-setup-eplugin/exchange-mapi-account-listener.c
@@ -686,7 +686,7 @@ mapi_account_changed (EAccountList *account_listener, EAccount *account)
gchar *profname = NULL, *uri = NULL;
ExchangeMAPIAccountListener *config_listener = exchange_mapi_accounts_peek_config_listener();
- profname = g_strdup_printf("%s %s", new_url->user, camel_url_get_param (new_url, "domain"));
+ profname = exchange_mapi_util_profile_name (new_url->user, camel_url_get_param (new_url, "domain"));
camel_url_set_param(new_url, "profile", profname);
g_free (profname);
@@ -719,7 +719,7 @@ mapi_account_changed (EAccountList *account_listener, EAccount *account)
gchar *profname = NULL, *uri = NULL;
ExchangeMAPIAccountListener *config_listener = exchange_mapi_accounts_peek_config_listener();
- profname = g_strdup_printf("%s %s", new_url->user, camel_url_get_param (new_url, "domain"));
+ profname = exchange_mapi_util_profile_name (new_url->user, camel_url_get_param (new_url, "domain"));
camel_url_set_param(new_url, "profile", profname);
g_free (profname);
diff --git a/src/account-setup-eplugin/exchange-mapi-account-setup.c b/src/account-setup-eplugin/exchange-mapi-account-setup.c
index 306182e..7bad6fe 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-setup.c
+++ b/src/account-setup-eplugin/exchange-mapi-account-setup.c
@@ -200,6 +200,17 @@ validate_credentials (GtkWidget *widget, EConfig *config)
url = camel_url_new (e_account_get_string (target_account->account, E_ACCOUNT_SOURCE_URL), NULL);
domain_name = camel_url_get_param (url, "domain");
+ /* Silently remove domain part from a user name when user enters it as such.
+ This change will be visible in the UI on new edit open. */
+ if (url->user && strchr (url->user, '\\')) {
+ gchar *tmp, *at;
+
+ at = strrchr (url->user, '\\') + 1;
+ tmp = g_strdup (at);
+ camel_url_set_user (url, tmp);
+ g_free (tmp);
+ }
+
if (!url->user || !*url->user || !url->host || !*url->host || !domain_name || !*domain_name) {
e_notice (NULL, GTK_MESSAGE_ERROR, "%s", _("Server, username and domain name cannot be empty. Please fill them with correct values."));
return;
@@ -229,7 +240,7 @@ validate_credentials (GtkWidget *widget, EConfig *config)
/* Things are successful */
gchar *profname = NULL, *uri = NULL;
- profname = g_strdup_printf("%s %s", url->user, domain_name);
+ profname = exchange_mapi_util_profile_name (url->user, domain_name);
camel_url_set_param(url, "profile", profname);
g_free (profname);
diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c
index 65faf75..7ae454d 100644
--- a/src/libexchangemapi/exchange-mapi-connection.c
+++ b/src/libexchangemapi/exchange-mapi-connection.c
@@ -3264,7 +3264,7 @@ exchange_mapi_create_profile (const char *username, const char *password, const
LOCK ();
- profname = g_strdup_printf("%s %s", username, domain);
+ profname = exchange_mapi_util_profile_name (username, domain);
if (!ensure_mapi_init_called ()) {
UNLOCK ();
diff --git a/src/libexchangemapi/exchange-mapi-utils.c b/src/libexchangemapi/exchange-mapi-utils.c
index 8a6a4e1..b1bc412 100644
--- a/src/libexchangemapi/exchange-mapi-utils.c
+++ b/src/libexchangemapi/exchange-mapi-utils.c
@@ -599,3 +599,20 @@ exchange_crlf_to_lf (const char *in)
return out;
}
+/**
+ * exchange_mapi_util_profile_name:
+ * @username: User name of the profile
+ * @domain: Domain name of the profile
+ *
+ * Constructs profile name from given @username and @domain and
+ * returns it as a newly allocated string.
+ **/
+gchar *
+exchange_mapi_util_profile_name (const gchar *username, const gchar *domain)
+{
+ gchar *res;
+
+ res = g_strdup_printf ("%s %s", username, domain);
+
+ return g_strcanon (res, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@", '_');
+}
diff --git a/src/libexchangemapi/exchange-mapi-utils.h b/src/libexchangemapi/exchange-mapi-utils.h
index 4f82711..680b825 100644
--- a/src/libexchangemapi/exchange-mapi-utils.h
+++ b/src/libexchangemapi/exchange-mapi-utils.h
@@ -72,5 +72,7 @@ exchange_lf_to_crlf (const char *in);
char *
exchange_crlf_to_lf (const char *in);
+gchar *exchange_mapi_util_profile_name (const gchar *username, const gchar *domain);
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]