Skip to content

Commit

Permalink
Merge pull request jlaffaye#62 from svett/fix-filename-parsing
Browse files Browse the repository at this point in the history
Fix incorrect filename parsing
  • Loading branch information
jlaffaye authored Dec 29, 2016
2 parents 988909a + 0856606 commit 95f4fe9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package ftp
import (
"bufio"
"errors"
"fmt"
"io"
"net"
"net/textproto"
Expand Down Expand Up @@ -342,7 +343,7 @@ func parseLsListLineName(line string, fields []string, offset int) string {
return ""
}

match := fields[offset-1]
match := fmt.Sprintf(" %s ", fields[offset-1])
index := strings.Index(line, match)
if index == -1 {
return ""
Expand Down
2 changes: 2 additions & 0 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var listTests = []line{
// UNIX ls -l style
{"drwxr-xr-x 3 110 1002 3 Dec 02 2009 pub", "pub", 0, EntryTypeFolder, time.Date(2009, time.December, 2, 0, 0, 0, 0, time.UTC)},
{"drwxr-xr-x 3 110 1002 3 Dec 02 2009 p u b", "p u b", 0, EntryTypeFolder, time.Date(2009, time.December, 2, 0, 0, 0, 0, time.UTC)},
{"-rw-r--r-- 1 marketwired marketwired 12016 Mar 16 2016 2016031611G087802-001.newsml", "2016031611G087802-001.newsml", 12016, EntryTypeFile, time.Date(2016, time.March, 16, 0, 0, 0, 0, time.UTC)},

{"-rwxr-xr-x 3 110 1002 1234567 Dec 02 2009 fileName", "fileName", 1234567, EntryTypeFile, time.Date(2009, time.December, 2, 0, 0, 0, 0, time.UTC)},
{"lrwxrwxrwx 1 root other 7 Jan 25 00:17 bin -> usr/bin", "bin -> usr/bin", 0, EntryTypeLink, time.Date(thisYear, time.January, 25, 0, 17, 0, 0, time.UTC)},

Expand Down

0 comments on commit 95f4fe9

Please sign in to comment.