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() {