summaryrefslogtreecommitdiff
path: root/src/rust/protover/protoset.rs
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-08-17 09:38:26 -0400
committerNick Mathewson <nickm@torproject.org>2018-08-17 09:38:26 -0400
commite0b8c53f56441eb0a8d9ebc5d579b520a31291c6 (patch)
tree7659d9fe8666da562c332ba9735bca38a7da6793 /src/rust/protover/protoset.rs
parentbedc0b0b8f66b73a1052dddfdd1fb0c798bff48a (diff)
parent700f5bcc43fb959927dd1cae4e2943d115144850 (diff)
downloadtor-e0b8c53f56441eb0a8d9ebc5d579b520a31291c6.tar.gz
tor-e0b8c53f56441eb0a8d9ebc5d579b520a31291c6.zip
Merge branch 'maint-0.3.4'
Diffstat (limited to 'src/rust/protover/protoset.rs')
-rw-r--r--src/rust/protover/protoset.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/rust/protover/protoset.rs b/src/rust/protover/protoset.rs
index a670f796bf..db33592f95 100644
--- a/src/rust/protover/protoset.rs
+++ b/src/rust/protover/protoset.rs
@@ -341,11 +341,9 @@ impl FromStr for ProtoSet {
/// ```
fn from_str(version_string: &str) -> Result<Self, Self::Err> {
let mut pairs: Vec<(Version, Version)> = Vec::new();
- let pieces: ::std::str::Split<char> = version_string.trim().split(',');
-
- for piece in pieces {
- let p: &str = piece.trim();
+ let pieces: ::std::str::Split<char> = version_string.split(',');
+ for p in pieces {
if p.is_empty() {
continue;
} else if p.contains('-') {
@@ -370,7 +368,7 @@ impl FromStr for ProtoSet {
pairs.push((v, v));
}
}
- // If we were passed in an empty string, or a bunch of whitespace, or
+ // If we were passed in an empty string, or
// simply a comma, or a pile of commas, then return an empty ProtoSet.
if pairs.len() == 0 {
return Ok(ProtoSet::default());
@@ -562,6 +560,13 @@ mod test {
}
#[test]
+ fn test_versions_from_str_whitespace() {
+ assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("1,2\n"));
+ assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("1\r,2"));
+ assert_eq!(Err(ProtoverError::Unparseable), ProtoSet::from_str("1,\t2"));
+ }
+
+ #[test]
fn test_versions_from_str_overlap() {
assert_eq!(Err(ProtoverError::Overlap), ProtoSet::from_str("1-3,2-4"));
}