summaryrefslogtreecommitdiff
path: root/src
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
commitac721bd3b4223586b004df5f8be1b05069bf6855 (patch)
treeadffd0a9c918a0059caf0f8cd7cb6ec2ea4baddd /src
parentb49355915bf063448cf338fbb76061b601e5e333 (diff)
parentcc93f175ed6f7495b4d50cdaad0527f718da77f5 (diff)
downloadtor-ac721bd3b4223586b004df5f8be1b05069bf6855.tar.gz
tor-ac721bd3b4223586b004df5f8be1b05069bf6855.zip
Merge branch 'maint-0.3.3' into maint-0.3.4
Diffstat (limited to 'src')
-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 4afc50edf8..61b21ede98 100644
--- a/src/rust/protover/protoset.rs
+++ b/src/rust/protover/protoset.rs
@@ -348,7 +348,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)?;
@@ -539,6 +539,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,!"));
}