From ce47e7ea3d5eaeeb35691d66dd712a888f3a6a33 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sun, 16 Mar 2025 21:31:34 +0000 Subject: [PATCH] Fix sending server passwords with spaces in them Fix #1928 Fix #1899 --- src/IRCSock.cpp | 2 +- test/integration/tests/core.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index c07fcf37..2580406e 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -1323,7 +1323,7 @@ void CIRCSock::Connected() { PutIRC("CAP LS 302"); if (!sPass.empty()) { - PutIRC("PASS " + sPass); + PutIRC(CMessage(CNick(), "PASS", {sPass})); } PutIRC("NICK " + sNick); diff --git a/test/integration/tests/core.cpp b/test/integration/tests/core.cpp index 2a7a62d0..6d61a65e 100644 --- a/test/integration/tests/core.cpp +++ b/test/integration/tests/core.cpp @@ -964,5 +964,22 @@ TEST_F(ZNCTest, SaslAuthAbort) { client.ReadUntil(":irc.znc.in 906 foo :SASL authentication aborted"); } +TEST_F(ZNCTest, SpacedServerPassword) { + auto znc = Run(); + auto ircd = ConnectIRCd(); + auto client = LoginClient(); + client.Write("znc delserver 127.0.0.1"); + client.Write("znc addserver 127.0.0.1 6667 a b"); + client.Write("znc jump"); + auto ircd2 = ConnectIRCd(); + ircd2.ReadUntil("PASS :a b"); + client.Write("znc delserver 127.0.0.1"); + client.Write("znc addserver 127.0.0.1 6667 a"); + client.Write("znc jump"); + auto ircd3 = ConnectIRCd(); + // No : + ircd3.ReadUntil("PASS a"); +} + } // namespace } // namespace znc_inttest