tolerate bare newlines in gophermap parsing (non CRLF)
This commit is contained in:
parent
4d861a2c39
commit
751f423f11
|
@ -24,14 +24,11 @@ func Parse(input io.Reader) (gopher.MapDocument, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(line) > 2 && !bytes.Equal(line, []byte(".\r\n")) {
|
line = bytes.TrimSuffix(bytes.TrimSuffix(line, []byte{'\n'}), []byte{'\r'})
|
||||||
if line[len(line)-2] != '\r' || line[len(line)-1] != '\n' {
|
if len(line) > 0 && !bytes.Equal(line, []byte(".")) {
|
||||||
return nil, InvalidLine(num)
|
|
||||||
}
|
|
||||||
|
|
||||||
item := gopher.MapItem{Type: sr.Status(line[0])}
|
item := gopher.MapItem{Type: sr.Status(line[0])}
|
||||||
|
|
||||||
spl := bytes.Split(line[1:len(line)-2], []byte{'\t'})
|
spl := bytes.Split(line[1:], []byte{'\t'})
|
||||||
if item.Type != gopher.InfoMessageType && len(spl) != 4 {
|
if item.Type != gopher.InfoMessageType && len(spl) != 4 {
|
||||||
return nil, InvalidLine(num)
|
return nil, InvalidLine(num)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue