- for l in lines {
- if let Ok(l) = l {
- let l = l.as_ref().trim();
- // Allow (ignore) blank lines
- if l.is_empty() {
- continue;
- }
- // Expected format
- // <valid-hash><space><space-or-*><filename>
- let (line_alg, bytes, filename) = match l
- .find(' ')
- .and_then(|space_pos| (l.get(0..space_pos)).zip(l.get(space_pos + 2..)))
- .and_then(|(maybe_hash, filename)| {
+ for l in lines.flatten() {
+ let l = l.as_ref().trim();
+ // Allow (ignore) blank lines
+ if l.is_empty() {
+ continue;
+ }
+ // Expected format
+ // <valid-hash><space><space-or-*><filename>
+ let (line_alg, bytes, filename) = match l
+ .find(' ')
+ .and_then(|space_pos| {
+ // Char before filename should be space for text or * for binary
+ match l.chars().nth(space_pos + 1) {
+ Some(' ') | Some('*') => (l.get(..space_pos)).zip(l.get(space_pos + 2..)),
+ _ => None,
+ }
+ })
+ .and_then(|(maybe_hash, filename)| {
+ // Filename should be in this position without extra whitespace
+ if filename.trim() == filename {