1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

Merge pull request #43 from ailin-nemui/server-outgoing

remove newline from "server outgoing modify"
This commit is contained in:
ailin-nemui 2021-10-10 12:45:21 +02:00 committed by GitHub
commit ea961623f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 13 deletions

View File

@ -151,7 +151,7 @@ irc.c:
"whois default event", SERVER_REC, char *args, char *sender_nick, char *sender_address
"server incoming", SERVER_REC, char *data
"server outgoing modify", SERVER_REC, GString *data
"server outgoing modify", SERVER_REC, GString *data, int crlf
(for perl parser..)
"redir "<cmd>, SERVER_REC, char *args, char *sender_nick, char *sender_address

View File

@ -718,6 +718,7 @@ static int server_cmd_timeout(IRC_SERVER_REC *server, gint64 now)
GString *str;
long usecs;
char *cmd;
int crlf;
if (!IS_IRC_SERVER(server))
return 0;
@ -741,15 +742,29 @@ static int server_cmd_timeout(IRC_SERVER_REC *server, gint64 now)
/* send command */
str = g_string_new(cmd);
signal_emit("server outgoing modify", 2, server, str);
if (str->len > 2 && str->str[str->len - 2] == '\r')
crlf = 2;
else if (str->len > 1 && str->str[str->len - 1] == '\n')
crlf = 1;
else
crlf = 0;
if (crlf)
g_string_truncate(str, str->len - crlf);
signal_emit("server outgoing modify", 3, server, str, crlf);
if (str->len) {
if (crlf == 2)
g_string_append(str, "\r\n");
else if (crlf == 1)
g_string_append(str, "\n");
irc_server_send_data(server, str->str, str->len);
/* add to rawlog without [CR+]LF */
if (str->len > 2 && str->str[str->len - 2] == '\r')
str->str[str->len - 2] = '\0';
else if (str->str[str->len - 1] == '\n')
str->str[str->len - 1] = '\0';
if (crlf)
g_string_truncate(str, str->len - crlf);
rawlog_output(server->rawlog, str->str);
server_redirect_command(server, str->str, redirect);
}

View File

@ -115,20 +115,34 @@ void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd, int irc_send_whe
if (!raw) {
/* Add CR+LF to command */
g_string_append_c(str, 13);
g_string_append_c(str, 10);
g_string_append(str, "\r\n");
}
if (irc_send_when == IRC_SEND_NOW) {
signal_emit("server outgoing modify", 2, server, str);
int crlf;
if (str->len > 2 && str->str[str->len - 2] == '\r')
crlf = 2;
else if (str->len > 1 && str->str[str->len - 1] == '\n')
crlf = 1;
else
crlf = 0;
if (crlf)
g_string_truncate(str, str->len - crlf);
signal_emit("server outgoing modify", 3, server, str, crlf);
if (str->len) {
if (crlf == 2)
g_string_append(str, "\r\n");
else if (crlf == 1)
g_string_append(str, "\n");
irc_server_send_data(server, str->str, str->len);
/* add to rawlog without [CR+]LF */
if (str->len > 2 && str->str[str->len - 2] == '\r')
str->str[str->len - 2] = '\0';
else if (str->str[str->len - 1] == '\n')
str->str[str->len - 1] = '\0';
if (crlf)
g_string_truncate(str, str->len - crlf);
rawlog_output(server->rawlog, str->str);
server_redirect_command(server, str->str, server->redirect_next);
}