Updated parsing to support colons within arguments.
This commit is contained in:
parent
c5d2cdb891
commit
aaf5013407
1 changed files with 16 additions and 3 deletions
|
@ -83,9 +83,9 @@ impl FromStr for Message {
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let suffix = if state.contains(":") {
|
let suffix = if state.contains(" :") {
|
||||||
let suffix = state.find(':').map(|i| &state[i+1..state.len()-2]);
|
let suffix = state.find(" :").map(|i| &state[i+2..state.len()-2]);
|
||||||
state = state.find(':').map_or("", |i| &state[..i]);
|
state = state.find(" :").map_or("", |i| &state[..i+1]);
|
||||||
suffix
|
suffix
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -196,6 +196,19 @@ mod test {
|
||||||
assert_eq!(":test!test@test PRIVMSG test :Still testing!\r\n".to_message(), message);
|
assert_eq!(":test!test@test PRIVMSG test :Still testing!\r\n".to_message(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn to_message_with_colon_in_arg() {
|
||||||
|
// Apparently, UnrealIRCd (and perhaps some others) send some messages that include
|
||||||
|
// colons within individual parameters. So, let's make sure it parses correctly.
|
||||||
|
let message = Message {
|
||||||
|
prefix: Some(format!("test!test@test")),
|
||||||
|
command: format!("COMMAND"),
|
||||||
|
args: vec![format!("ARG:test")],
|
||||||
|
suffix: Some(format!("Still testing!")),
|
||||||
|
};
|
||||||
|
assert_eq!(":test!test@test COMMAND ARG:test :Still testing!\r\n".to_message(), message);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_fail]
|
#[should_fail]
|
||||||
fn to_message_invalid_format() {
|
fn to_message_invalid_format() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue