From 87bc5d661b7a0db9e562f3f07ebd8c2054a8e3d6 Mon Sep 17 00:00:00 2001 From: Dmitriy Denisov Date: Mon, 4 Jan 2016 11:11:11 +1000 Subject: [PATCH 1/2] fix parseUnixLIST parseUnixLIST fails if "-"-char in group, eg. FU-Berlin in: lrw-r--r-- 1 ZEDAT FU-Berlin ...... --- ftp_list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftp_list.go b/ftp_list.go index 854ddb1..41b6171 100644 --- a/ftp_list.go +++ b/ftp_list.go @@ -155,7 +155,7 @@ func (ftp *FTP) parseNLST(data []string, basePath string) (files []string, direc // Parse the response of a LIST // Return an array with the files, one with the directories and one with the links func (ftp *FTP) parseUnixLIST(data []string, basePath string) (files []string, directories []string, links []string, err error) { - var pattern = regexp.MustCompile(`([-ld])([-rwx]+)\s{2,}\d+\s(\d|\w+)\s{2,}(\(\?\)|\d+|\w+)\s{2,}(\d+)\s*(\w+\s*\d+\s*\d+\:*\d*)\s(\S+)`) + var pattern = regexp.MustCompile(`([-ld])([-rwx]+)\s{2,}\d+\s(\d|\w+)\s{2,}(\(\?\)|\d+|[\w\-]+)\s{1,}(\d+)\s*(\w+\s*\d+\s*\d+\:*\d*)\s(\S+)`) for _, line := range data { match := pattern.FindStringSubmatch(line) /*for i, val := range match { From 23d044f3cae31a2777f6a6a6d556d306bcbcb5ac Mon Sep 17 00:00:00 2001 From: Dmitriy Denisov Date: Mon, 4 Jan 2016 13:47:29 +1000 Subject: [PATCH 2/2] comments for regexp pattern in parseUnixList --- ftp_list.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ftp_list.go b/ftp_list.go index 41b6171..3fa02cf 100644 --- a/ftp_list.go +++ b/ftp_list.go @@ -155,7 +155,14 @@ func (ftp *FTP) parseNLST(data []string, basePath string) (files []string, direc // Parse the response of a LIST // Return an array with the files, one with the directories and one with the links func (ftp *FTP) parseUnixLIST(data []string, basePath string) (files []string, directories []string, links []string, err error) { - var pattern = regexp.MustCompile(`([-ld])([-rwx]+)\s{2,}\d+\s(\d|\w+)\s{2,}(\(\?\)|\d+|[\w\-]+)\s{1,}(\d+)\s*(\w+\s*\d+\s*\d+\:*\d*)\s(\S+)`) + var pattern = regexp.MustCompile(`([-ld])` + //dir,link flags -dbclps + `([-rwxs]+)\s+` + //permissions + `\d+\s+` + //items count + `([\d\w\-]+)\s+` + //owner + `(\(\?\)|[\d\w\-]+)\s+` + //group + `(\d+)\s*` + //size + `(\w+\s*\d+\s*\d+\:*\d*)\s+` + //date|time + `(\S+)` /*name*/) for _, line := range data { match := pattern.FindStringSubmatch(line) /*for i, val := range match {