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
1 changed files with 7 additions and 2 deletions

View File

@ -197,8 +197,12 @@ 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 {
// Ignore parsing errors for bad servers for INFO types
if i.Type != INFO {
return err return err
} }
port = 0
}
i.Port = port i.Port = port
if len(parts) >= 4 { if len(parts) >= 4 {
@ -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)
} }