diff options
author | Teddy Wing | 2016-08-06 20:43:09 -0400 |
---|---|---|
committer | Teddy Wing | 2016-08-06 20:43:09 -0400 |
commit | 874d653d420ea98680dd820f3bdd60afb3931747 (patch) | |
tree | afc99ad07404d140fa0657915817338365072235 | |
parent | 0712752918dfb47188c76c5bbaa432a1312b019d (diff) | |
download | Passextract-874d653d420ea98680dd820f3bdd60afb3931747.tar.bz2 |
strip_key: Fix for values that contain ": "
Values that contained ": " would not be parsed correctly for copying to
the clipboard. If, for example, a password contained ": ", those
characters and any following them wouldn't be copied. This change allows
such passwords to be copied correctly.
-rw-r--r-- | src/main.rs | 4 | ||||
-rw-r--r-- | testdata/test-file.txt | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 37ddb5e..c09eb4d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,9 +29,9 @@ struct Point { /// let value = strip_key("e: email@example.com"); /// assert_eq!(value, "email@example.com"); /// ``` -fn strip_key(line: &str) -> &str { +fn strip_key(line: &str) -> String { let strings: Vec<&str> = line.split(": ").collect(); - strings[1] + strings[1..].join(": ") } fn move_selection(term: &mut Terminal, selection: &mut Point, style: Cell, amount: isize) { diff --git a/testdata/test-file.txt b/testdata/test-file.txt index a37ab5b..3ba15c0 100644 --- a/testdata/test-file.txt +++ b/testdata/test-file.txt @@ -10,3 +10,4 @@ p: qp4ntcq4i'yz/4hmy;4icmA $Y I$zw#On7i4 More description p: t ivyAKW$ Jybi3hz iq3'y +p: QV$OTJn4: q43 hiqb3i43hya43 |