summaryrefslogtreecommitdiff
path: root/src/plugins/irc/irc-server.c
diff options
context:
space:
mode:
authorValentin Lorentz <progval+git@progval.net>2021-08-27 18:57:06 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-05-17 16:37:19 +0200
commit980b075ce970b1e210289233e69d716871763885 (patch)
tree45a5daf56022295d6dca43578e1ca90e1073c9b4 /src/plugins/irc/irc-server.c
parentd0f1859ef5199f3522897e1b363ac088fe33f89b (diff)
downloadweechat-980b075ce970b1e210289233e69d716871763885.zip
irc: Implement the UTF8ONLY IRCv3 specification
https://ircv3.net/specs/extensions/utf8-only
Diffstat (limited to 'src/plugins/irc/irc-server.c')
-rw-r--r--src/plugins/irc/irc-server.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 74132984c..a608a287b 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -2954,9 +2954,22 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags,
weechat_plugin->name,
server->name);
}
- msg_encoded = irc_message_convert_charset (ptr_msg, pos_encode,
- "charset_encode",
- modifier_data);
+
+
+ if (!irc_server_get_isupport_value (server, "UTF8ONLY"))
+ {
+ /* "Clients implementing this specification MUST NOT send
+ * non-UTF-8 data to the server once they have seen
+ * this token."
+ * "If a client implementing this specification sees this token,
+ * they MUST set their outgoing encoding to UTF-8 without
+ * requiring any user intervention."
+ * -- https://ircv3.net/specs/extensions/utf8-only
+ */
+ msg_encoded = irc_message_convert_charset (ptr_msg, pos_encode,
+ "charset_encode",
+ modifier_data);
+ }
}
if (msg_encoded)
@@ -3549,9 +3562,18 @@ irc_server_msgq_flush ()
irc_recv_msgq->server->name);
}
}
- msg_decoded = irc_message_convert_charset (
- ptr_msg, pos_decode,
- "charset_decode", modifier_data);
+ if (!irc_server_get_isupport_value (irc_recv_msgq->server,
+ "UTF8ONLY"))
+ {
+ /* "Servers publishing this token MUST NOT relay content
+ * [...] containing non-UTF-8 data to clients"
+ * -- https://ircv3.net/specs/extensions/utf8-only
+ * Therefore, no need to decode, we are sure it is UTF-8.
+ */
+ msg_decoded = irc_message_convert_charset (
+ ptr_msg, pos_decode,
+ "charset_decode", modifier_data);
+ }
}
/* replace WeeChat internal color codes by "?" */