mirror of
https://github.com/profanity-im/profanity.git
synced 2024-09-01 19:24:15 -04:00
Fix broken support for case-sensitive account names
Don't lower account name before calling accounts_get_account(). Only lower if there is no account with the given name and the name is interpreted as a jid. Updated unittests to test this behaviour. Fixes #725 .
This commit is contained in:
parent
6034b833be
commit
5b7f9dffbc
@ -386,12 +386,11 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
}
|
||||
|
||||
char *lower = g_utf8_strdown(user, -1);
|
||||
char *jid;
|
||||
g_free(def);
|
||||
|
||||
// connect with account
|
||||
ProfAccount *account = accounts_get_account(lower);
|
||||
ProfAccount *account = accounts_get_account(user);
|
||||
if (account) {
|
||||
// override account options with connect options
|
||||
if (altdomain != NULL)
|
||||
@ -414,7 +413,7 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args)
|
||||
account->password = NULL;
|
||||
} else {
|
||||
cons_show("Error evaluating password, see logs for details.");
|
||||
g_free(lower);
|
||||
g_free(user);
|
||||
account_free(account);
|
||||
return TRUE;
|
||||
}
|
||||
@ -432,7 +431,7 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args)
|
||||
|
||||
// connect with JID
|
||||
} else {
|
||||
jid = strdup(lower);
|
||||
jid = g_utf8_strdown(user, -1);
|
||||
char *passwd = ui_ask_password();
|
||||
conn_status = cl_ev_connect_jid(jid, passwd, altdomain, port, tls_policy);
|
||||
free(passwd);
|
||||
@ -444,7 +443,6 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
|
||||
options_destroy(options);
|
||||
g_free(lower);
|
||||
free(jid);
|
||||
|
||||
return TRUE;
|
||||
|
@ -89,29 +89,49 @@ void cmd_connect_fail_message(void **state)
|
||||
assert_true(result);
|
||||
}
|
||||
|
||||
void cmd_connect_lowercases_argument(void **state)
|
||||
void cmd_connect_lowercases_argument_with_no_account(void **state)
|
||||
{
|
||||
gchar *args[] = { "USER@server.ORG", NULL };
|
||||
|
||||
will_return(connection_get_status, JABBER_DISCONNECTED);
|
||||
|
||||
expect_string(accounts_get_account, name, "user@server.org");
|
||||
expect_string(accounts_get_account, name, "USER@server.ORG");
|
||||
will_return(accounts_get_account, NULL);
|
||||
|
||||
will_return(ui_ask_password, strdup("password"));
|
||||
|
||||
expect_cons_show("Connecting as user@server.org");
|
||||
|
||||
expect_any(session_connect_with_details, jid);
|
||||
expect_any(session_connect_with_details, passwd);
|
||||
expect_any(session_connect_with_details, altdomain);
|
||||
expect_any(session_connect_with_details, port);
|
||||
expect_string(session_connect_with_details, jid, "user@server.org");
|
||||
expect_string(session_connect_with_details, passwd, "password");
|
||||
expect_value(session_connect_with_details, altdomain, NULL);
|
||||
expect_value(session_connect_with_details, port, 0);
|
||||
will_return(session_connect_with_details, JABBER_CONNECTING);
|
||||
|
||||
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||
assert_true(result);
|
||||
}
|
||||
|
||||
void cmd_connect_lowercases_argument_with_account(void **state)
|
||||
{
|
||||
gchar *args[] = { "Jabber_org", NULL };
|
||||
ProfAccount *account = account_new("Jabber_org", "me@jabber.org", "password", NULL,
|
||||
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
will_return(connection_get_status, JABBER_DISCONNECTED);
|
||||
|
||||
expect_any(accounts_get_account, name);
|
||||
will_return(accounts_get_account, account);
|
||||
|
||||
expect_cons_show("Connecting with account Jabber_org as me@jabber.org");
|
||||
|
||||
expect_memory(session_connect_with_account, account, account, sizeof(account));
|
||||
will_return(session_connect_with_account, JABBER_CONNECTING);
|
||||
|
||||
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||
assert_true(result);
|
||||
}
|
||||
|
||||
void cmd_connect_asks_password_when_not_in_account(void **state)
|
||||
{
|
||||
gchar *args[] = { "jabber_org", NULL };
|
||||
|
@ -5,7 +5,8 @@ void cmd_connect_shows_message_when_undefined(void **state);
|
||||
void cmd_connect_when_no_account(void **state);
|
||||
void cmd_connect_with_altdomain_when_provided(void **state);
|
||||
void cmd_connect_fail_message(void **state);
|
||||
void cmd_connect_lowercases_argument(void **state);
|
||||
void cmd_connect_lowercases_argument_with_no_account(void **state);
|
||||
void cmd_connect_lowercases_argument_with_account(void **state);
|
||||
void cmd_connect_asks_password_when_not_in_account(void **state);
|
||||
void cmd_connect_shows_message_when_connecting_with_account(void **state);
|
||||
void cmd_connect_connects_with_account(void **state);
|
||||
|
@ -244,7 +244,10 @@ int main(int argc, char* argv[]) {
|
||||
unit_test_setup_teardown(cmd_connect_fail_message,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_connect_lowercases_argument,
|
||||
unit_test_setup_teardown(cmd_connect_lowercases_argument_with_account,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_connect_lowercases_argument_with_no_account,
|
||||
load_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_connect_asks_password_when_not_in_account,
|
||||
|
Loading…
Reference in New Issue
Block a user