Improve support for bad servers and hand-written/broken Gopher menus

This commit is contained in:
James Mills 2016-09-23 21:34:53 +10:00
parent d5262b612a
commit b02b629fe9
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6

View File

@ -197,7 +197,11 @@ func (i *Item) parse(line []byte) error {
port, err := strconv.Atoi(string(parts[3])) port, err := strconv.Atoi(string(parts[3]))
if err != nil { if err != nil {
return err // Ignore parsing errors for bad servers for INFO types
if i.Type != INFO {
return err
}
port = 0
} }
i.Port = port i.Port = port
@ -379,7 +383,8 @@ func (i *Item) FetchDirectory() (Directory, error) {
var i Item var i Item
err := i.parse(line) err := i.parse(line)
if err != nil { if err != nil {
return d, err log.Printf("Error parsing %q: %q", line, err)
continue
} }
d = append(d, i) d = append(d, i)
} }