1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-30 14:56:39 +02:00

Improved password hiding, code cleanup (bug #19229) (new commit after savannah crash)

This commit is contained in:
Sebastien Helleu
2007-03-16 08:40:10 +00:00
parent 7d5ea81f93
commit 4d64128ef2
12 changed files with 182 additions and 140 deletions
+13 -23
View File
@@ -2968,7 +2968,7 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
void
weechat_cmd_set_display_option (t_config_option *option, char *prefix, void *value)
{
char *color_name, *pos_nickserv, *pos_pwd, *value2;
char *color_name, *value2;
gui_printf (NULL, " %s%s%s%s = ",
(prefix) ? prefix : "",
@@ -3009,32 +3009,22 @@ weechat_cmd_set_display_option (t_config_option *option, char *prefix, void *val
if (*((char **)value))
{
value2 = strdup (*((char **)value));
pos_nickserv = NULL;
pos_pwd = NULL;
pos_nickserv = strstr (value2, "nickserv");
if (pos_nickserv)
if (value2)
{
pos_pwd = strstr (value2, "identify ");
if (!pos_pwd)
pos_pwd = strstr (value2, "register ");
}
if (cfg_log_hide_nickserv_pwd && pos_nickserv && pos_pwd)
{
pos_pwd += 9;
while (pos_pwd[0])
if (cfg_log_hide_nickserv_pwd)
{
pos_pwd[0] = '*';
pos_pwd++;
irc_hide_password (value2, 1);
if (strcmp (*((char **)value), value2) != 0)
gui_printf (NULL, _("%s(password hidden) "),
GUI_COLOR(COLOR_WIN_CHAT));
}
gui_printf (NULL, _("%s(password hidden) "),
GUI_COLOR(COLOR_WIN_CHAT));
gui_printf (NULL, "%s\"%s%s%s\"",
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR(COLOR_WIN_CHAT_HOST),
value2,
GUI_COLOR(COLOR_WIN_CHAT_DARK));
free (value2);
}
gui_printf (NULL, "%s\"%s%s%s\"",
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR(COLOR_WIN_CHAT_HOST),
value2,
GUI_COLOR(COLOR_WIN_CHAT_DARK));
free (value2);
}
else
gui_printf (NULL, "%s\"\"",
+3 -28
View File
@@ -31,6 +31,7 @@
#include "history.h"
#include "util.h"
#include "weeconfig.h"
#include "../irc/irc.h"
#include "../gui/gui.h"
@@ -40,32 +41,6 @@ t_history *history_global_ptr = NULL;
int num_history_global = 0;
/*
* history_hide_password: hide a nickserv password
*/
void
history_hide_password (char *string)
{
char *pos_pwd;
if (strstr (string, "nickserv "))
{
pos_pwd = strstr (string, "identify ");
if (!pos_pwd)
pos_pwd = strstr (string, "register ");
if (pos_pwd)
{
pos_pwd += 9;
while (pos_pwd[0])
{
pos_pwd[0] = '*';
pos_pwd++;
}
}
}
}
/*
* history_buffer_add: add a text/command to buffer's history
*/
@@ -87,7 +62,7 @@ history_buffer_add (void *buffer, char *string)
{
new_history->text = strdup (string);
if (cfg_log_hide_nickserv_pwd)
history_hide_password (new_history->text);
irc_hide_password (new_history->text, 1);
if (((t_gui_buffer *)(buffer))->history)
((t_gui_buffer *)(buffer))->history->prev_history = new_history;
@@ -137,7 +112,7 @@ history_global_add (char *string)
{
new_history->text = strdup (string);
if (cfg_log_hide_nickserv_pwd)
history_hide_password (new_history->text);
irc_hide_password (new_history->text, 1);
if (history_global)
history_global->prev_history = new_history;