From 199f591e78a0e8aa943601b78c956cb7852ed414 Mon Sep 17 00:00:00 2001 From: David Blajda Date: Thu, 3 Jan 2019 05:07:03 +0000 Subject: [PATCH] Handle the case of a single SOH in PRIVMSG --- src/client/mod.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/client/mod.rs b/src/client/mod.rs index 258c94b..a4b9dc4 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -336,7 +336,7 @@ impl ClientState { PRIVMSG(ref target, ref body) => { if body.starts_with('\u{001}') { let tokens: Vec<_> = { - let end = if body.ends_with('\u{001}') { + let end = if body.ends_with('\u{001}') && body.len() > 1 { body.len() - 1 } else { body.len() @@ -1234,6 +1234,21 @@ mod test { assert!(client.list_users("#test").is_none()) } + #[test] + fn handle_single_soh() { + let value = ":test!test@test PRIVMSG #test :\u{001}\r\n"; + let client = IrcClient::from_config(Config { + mock_initial_value: Some(value.to_owned()), + nickname: Some(format!("test")), + channels: Some(vec![format!("#test"), format!("#test2")]), + ..test_config() + }).unwrap(); + client.for_each_incoming(|message| { + println!("{:?}", message); + }).unwrap(); + } + + #[test] #[cfg(feature = "ctcp")] fn finger_response() {