mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
Improved password hiding, code cleanup (bug #19229) (new commit after savannah crash)
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2007-03-06
|
||||
ChangeLog - 2007-03-12
|
||||
|
||||
|
||||
Version 0.2.4 (under dev!):
|
||||
* improved password hiding, code cleanup (bug #19229)
|
||||
* added new return code in plugin API to force highlight (for message
|
||||
handlers only)
|
||||
* fixed bug with server buffer when "look_one_server_buffer" is ON and
|
||||
|
||||
+13
-23
@@ -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
@@ -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;
|
||||
|
||||
+18
-3
@@ -372,6 +372,8 @@ irc_display_mode (t_irc_server *server, t_gui_buffer *buffer,
|
||||
void
|
||||
irc_display_server (t_irc_server *server)
|
||||
{
|
||||
char *string;
|
||||
|
||||
gui_printf (NULL, "\n");
|
||||
gui_printf (NULL, _("%sServer: %s%s %s[%s%s%s]\n"),
|
||||
GUI_COLOR(COLOR_WIN_CHAT),
|
||||
@@ -417,9 +419,22 @@ irc_display_server (t_irc_server *server)
|
||||
server->realname);
|
||||
gui_printf (NULL, " server_hostname . . . . . : %s\n",
|
||||
(server->hostname) ? server->hostname : "");
|
||||
gui_printf (NULL, " server_command . . . . . . : %s\n",
|
||||
(server->command && server->command[0]) ?
|
||||
server->command : "");
|
||||
if (server->command && server->command[0])
|
||||
string = strdup (server->command);
|
||||
else
|
||||
string = NULL;
|
||||
if (string)
|
||||
{
|
||||
if (cfg_log_hide_nickserv_pwd)
|
||||
irc_hide_password (string, 1);
|
||||
gui_printf (NULL, " server_command . . . . . . : %s\n",
|
||||
string);
|
||||
free (string);
|
||||
}
|
||||
else
|
||||
gui_printf (NULL, " server_command . . . . . . : %s\n",
|
||||
(server->command && server->command[0]) ?
|
||||
server->command : "");
|
||||
gui_printf (NULL, " server_command_delay . . . : %d %s\n",
|
||||
server->command_delay,
|
||||
_("seconds"));
|
||||
|
||||
+54
-15
@@ -44,6 +44,58 @@
|
||||
#include "../gui/gui.h"
|
||||
|
||||
|
||||
/*
|
||||
* irc_hide_password: hide IRC password(s) in a string
|
||||
*/
|
||||
|
||||
void
|
||||
irc_hide_password (char *string, int look_for_nickserv)
|
||||
{
|
||||
char *pos_nickserv, *pos, *pos_pwd;
|
||||
|
||||
pos = string;
|
||||
while (1)
|
||||
{
|
||||
if (look_for_nickserv)
|
||||
{
|
||||
pos_nickserv = strstr (pos, "nickserv ");
|
||||
if (!pos_nickserv)
|
||||
return;
|
||||
pos = pos_nickserv + 9;
|
||||
while (pos[0] == ' ')
|
||||
pos++;
|
||||
if ((strncmp (pos, "identify ", 9) == 0)
|
||||
|| (strncmp (pos, "register ", 9) == 0))
|
||||
pos_pwd = pos + 9;
|
||||
else
|
||||
pos_pwd = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos_pwd = strstr (pos, "identify ");
|
||||
if (!pos_pwd)
|
||||
pos_pwd = strstr (pos, "register ");
|
||||
if (!pos_pwd)
|
||||
return;
|
||||
pos_pwd += 9;
|
||||
}
|
||||
|
||||
if (pos_pwd)
|
||||
{
|
||||
while (pos_pwd[0] == ' ')
|
||||
pos_pwd++;
|
||||
|
||||
while (pos_pwd[0] && (pos_pwd[0] != ';') && (pos_pwd[0] != ' ')
|
||||
&& (pos_pwd[0] != '"'))
|
||||
{
|
||||
pos_pwd[0] = '*';
|
||||
pos_pwd++;
|
||||
}
|
||||
pos = pos_pwd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_login: login to irc server
|
||||
*/
|
||||
@@ -1189,7 +1241,7 @@ irc_cmd_send_msg (t_irc_server *server, t_irc_channel *channel,
|
||||
t_gui_window *window;
|
||||
t_gui_buffer *buffer;
|
||||
char *pos, *pos_comma;
|
||||
char *msg_pwd_hidden, *pos_pwd;
|
||||
char *msg_pwd_hidden;
|
||||
t_irc_channel *ptr_channel;
|
||||
t_irc_nick *ptr_nick;
|
||||
char *string;
|
||||
@@ -1274,20 +1326,7 @@ irc_cmd_send_msg (t_irc_server *server, t_irc_channel *channel,
|
||||
{
|
||||
msg_pwd_hidden = strdup (pos);
|
||||
if (cfg_log_hide_nickserv_pwd)
|
||||
{
|
||||
pos_pwd = strstr (msg_pwd_hidden, "identify ");
|
||||
if (!pos_pwd)
|
||||
pos_pwd = strstr (msg_pwd_hidden, "register ");
|
||||
if (pos_pwd)
|
||||
{
|
||||
pos_pwd += 9;
|
||||
while (pos_pwd[0])
|
||||
{
|
||||
pos_pwd[0] = '*';
|
||||
pos_pwd++;
|
||||
}
|
||||
}
|
||||
}
|
||||
irc_hide_password (msg_pwd_hidden, 0);
|
||||
irc_display_prefix (server, server->buffer, PREFIX_SERVER);
|
||||
gui_printf_type (server->buffer, MSG_TYPE_NICK,
|
||||
"%s-%s%s%s- ",
|
||||
|
||||
@@ -472,6 +472,7 @@ extern void irc_display_server (t_irc_server *ptr_server);
|
||||
/* IRC commands issued by user (irc-send.c) */
|
||||
|
||||
extern void irc_login (t_irc_server *);
|
||||
extern void irc_hide_password (char *, int);
|
||||
extern int irc_cmd_send_admin (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_cmd_send_ame (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_cmd_send_amsg (t_irc_server *, t_irc_channel *, char *);
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2007-03-06
|
||||
ChangeLog - 2007-03-12
|
||||
|
||||
|
||||
Version 0.2.4 (under dev!):
|
||||
* improved password hiding, code cleanup (bug #19229)
|
||||
* added new return code in plugin API to force highlight (for message
|
||||
handlers only)
|
||||
* fixed bug with server buffer when "look_one_server_buffer" is ON and
|
||||
|
||||
@@ -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\"\"",
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -372,6 +372,8 @@ irc_display_mode (t_irc_server *server, t_gui_buffer *buffer,
|
||||
void
|
||||
irc_display_server (t_irc_server *server)
|
||||
{
|
||||
char *string;
|
||||
|
||||
gui_printf (NULL, "\n");
|
||||
gui_printf (NULL, _("%sServer: %s%s %s[%s%s%s]\n"),
|
||||
GUI_COLOR(COLOR_WIN_CHAT),
|
||||
@@ -417,9 +419,22 @@ irc_display_server (t_irc_server *server)
|
||||
server->realname);
|
||||
gui_printf (NULL, " server_hostname . . . . . : %s\n",
|
||||
(server->hostname) ? server->hostname : "");
|
||||
gui_printf (NULL, " server_command . . . . . . : %s\n",
|
||||
(server->command && server->command[0]) ?
|
||||
server->command : "");
|
||||
if (server->command && server->command[0])
|
||||
string = strdup (server->command);
|
||||
else
|
||||
string = NULL;
|
||||
if (string)
|
||||
{
|
||||
if (cfg_log_hide_nickserv_pwd)
|
||||
irc_hide_password (string, 1);
|
||||
gui_printf (NULL, " server_command . . . . . . : %s\n",
|
||||
string);
|
||||
free (string);
|
||||
}
|
||||
else
|
||||
gui_printf (NULL, " server_command . . . . . . : %s\n",
|
||||
(server->command && server->command[0]) ?
|
||||
server->command : "");
|
||||
gui_printf (NULL, " server_command_delay . . . : %d %s\n",
|
||||
server->command_delay,
|
||||
_("seconds"));
|
||||
|
||||
+54
-15
@@ -44,6 +44,58 @@
|
||||
#include "../gui/gui.h"
|
||||
|
||||
|
||||
/*
|
||||
* irc_hide_password: hide IRC password(s) in a string
|
||||
*/
|
||||
|
||||
void
|
||||
irc_hide_password (char *string, int look_for_nickserv)
|
||||
{
|
||||
char *pos_nickserv, *pos, *pos_pwd;
|
||||
|
||||
pos = string;
|
||||
while (1)
|
||||
{
|
||||
if (look_for_nickserv)
|
||||
{
|
||||
pos_nickserv = strstr (pos, "nickserv ");
|
||||
if (!pos_nickserv)
|
||||
return;
|
||||
pos = pos_nickserv + 9;
|
||||
while (pos[0] == ' ')
|
||||
pos++;
|
||||
if ((strncmp (pos, "identify ", 9) == 0)
|
||||
|| (strncmp (pos, "register ", 9) == 0))
|
||||
pos_pwd = pos + 9;
|
||||
else
|
||||
pos_pwd = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos_pwd = strstr (pos, "identify ");
|
||||
if (!pos_pwd)
|
||||
pos_pwd = strstr (pos, "register ");
|
||||
if (!pos_pwd)
|
||||
return;
|
||||
pos_pwd += 9;
|
||||
}
|
||||
|
||||
if (pos_pwd)
|
||||
{
|
||||
while (pos_pwd[0] == ' ')
|
||||
pos_pwd++;
|
||||
|
||||
while (pos_pwd[0] && (pos_pwd[0] != ';') && (pos_pwd[0] != ' ')
|
||||
&& (pos_pwd[0] != '"'))
|
||||
{
|
||||
pos_pwd[0] = '*';
|
||||
pos_pwd++;
|
||||
}
|
||||
pos = pos_pwd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_login: login to irc server
|
||||
*/
|
||||
@@ -1189,7 +1241,7 @@ irc_cmd_send_msg (t_irc_server *server, t_irc_channel *channel,
|
||||
t_gui_window *window;
|
||||
t_gui_buffer *buffer;
|
||||
char *pos, *pos_comma;
|
||||
char *msg_pwd_hidden, *pos_pwd;
|
||||
char *msg_pwd_hidden;
|
||||
t_irc_channel *ptr_channel;
|
||||
t_irc_nick *ptr_nick;
|
||||
char *string;
|
||||
@@ -1274,20 +1326,7 @@ irc_cmd_send_msg (t_irc_server *server, t_irc_channel *channel,
|
||||
{
|
||||
msg_pwd_hidden = strdup (pos);
|
||||
if (cfg_log_hide_nickserv_pwd)
|
||||
{
|
||||
pos_pwd = strstr (msg_pwd_hidden, "identify ");
|
||||
if (!pos_pwd)
|
||||
pos_pwd = strstr (msg_pwd_hidden, "register ");
|
||||
if (pos_pwd)
|
||||
{
|
||||
pos_pwd += 9;
|
||||
while (pos_pwd[0])
|
||||
{
|
||||
pos_pwd[0] = '*';
|
||||
pos_pwd++;
|
||||
}
|
||||
}
|
||||
}
|
||||
irc_hide_password (msg_pwd_hidden, 0);
|
||||
irc_display_prefix (server, server->buffer, PREFIX_SERVER);
|
||||
gui_printf_type (server->buffer, MSG_TYPE_NICK,
|
||||
"%s-%s%s%s- ",
|
||||
|
||||
@@ -472,6 +472,7 @@ extern void irc_display_server (t_irc_server *ptr_server);
|
||||
/* IRC commands issued by user (irc-send.c) */
|
||||
|
||||
extern void irc_login (t_irc_server *);
|
||||
extern void irc_hide_password (char *, int);
|
||||
extern int irc_cmd_send_admin (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_cmd_send_ame (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_cmd_send_amsg (t_irc_server *, t_irc_channel *, char *);
|
||||
|
||||
Reference in New Issue
Block a user