From f4f49c6dd3c433a1821bbe97a6f3c9454e10dc4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Miedzi=C5=84ski?= Date: Wed, 15 Mar 2017 17:11:19 +0100 Subject: [PATCH] Ignore CTCP PINGs without timestamps --- src/client/server/mod.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/client/server/mod.rs b/src/client/server/mod.rs index b48d7b8..c53f86e 100644 --- a/src/client/server/mod.rs +++ b/src/client/server/mod.rs @@ -469,7 +469,9 @@ impl IrcServer { try!(self.send_ctcp_internal(resp, "SOURCE https://github.com/aatxe/irc")); self.send_ctcp_internal(resp, "SOURCE") }, - "PING" => self.send_ctcp_internal(resp, &format!("PING {}", tokens[1])), + "PING" if tokens.len() > 1 => { + self.send_ctcp_internal(resp, &format!("PING {}", tokens[1])) + }, "TIME" => self.send_ctcp_internal(resp, &format!( "TIME :{}", now().rfc822z() )), @@ -860,4 +862,15 @@ mod test { assert_eq!(&get_server_value(server)[..], "NOTICE test :\u{001}USERINFO :Testing.\u{001}\ \r\n"); } + + #[test] + #[cfg(feature = "ctcp")] + fn ctcp_ping_no_timestamp() { + let value = ":test!test@test PRIVMSG test :\u{001}PING\u{001}\r\n"; + let server = IrcServer::from_connection(test_config(), MockConnection::new(value)); + for message in server.iter() { + println!("{:?}", message); + } + assert_eq!(&get_server_value(server)[..], ""); + } }