summaryrefslogtreecommitdiff
path: root/src/rust/protover
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-08-17 09:29:46 -0400
committerNick Mathewson <nickm@torproject.org>2018-08-17 09:29:46 -0400
commitbedc0b0b8f66b73a1052dddfdd1fb0c798bff48a (patch)
tree2e3a8cf012556ae745bc8d02ae1557702ae2cb6e /src/rust/protover
parent042aed3f1d3c0da10cce451f103735036407aa53 (diff)
parentac721bd3b4223586b004df5f8be1b05069bf6855 (diff)
downloadtor-bedc0b0b8f66b73a1052dddfdd1fb0c798bff48a.tar.gz
tor-bedc0b0b8f66b73a1052dddfdd1fb0c798bff48a.zip
Merge branch 'maint-0.3.4'
Diffstat (limited to 'src/rust/protover')
-rw-r--r--src/rust/protover/protoset.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/rust/protover/protoset.rs b/src/rust/protover/protoset.rs
index 5cea03983a..a670f796bf 100644
--- a/src/rust/protover/protoset.rs
+++ b/src/rust/protover/protoset.rs
@@ -349,7 +349,7 @@ impl FromStr for ProtoSet {
if p.is_empty() {
continue;
} else if p.contains('-') {
- let mut pair = p.split('-');
+ let mut pair = p.splitn(2, '-');
let low = pair.next().ok_or(ProtoverError::Unparseable)?;
let high = pair.next().ok_or(ProtoverError::Unparseable)?;
@@ -540,6 +540,18 @@ mod test {
}
#[test]
+ fn test_versions_from_str_hyphens() {
+ assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("--1"));
+ assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("-1-2"));
+ assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("1--2"));
+ }
+
+ #[test]
+ fn test_versions_from_str_triple() {
+ assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("1-2-3"));
+ }
+
+ #[test]
fn test_versions_from_str_1exclam() {
assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("1,!"));
}