Merge pull request #171 from Blajda/handle_single_soh

Handle the case of a single SOH in PRIVMSG
This commit is contained in:
Aaron Weiss 2019-01-04 13:21:49 -05:00 committed by GitHub
commit 885e96a495
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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