From 29e710836007c8946d636a68b7dfaea6ee44028b Mon Sep 17 00:00:00 2001 From: tjpcc Date: Thu, 7 Sep 2023 15:14:11 -0600 Subject: fix loop exit conditions on extended gophermap parsing --- gopher/gophermap/extended.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'gopher/gophermap/extended.go') diff --git a/gopher/gophermap/extended.go b/gopher/gophermap/extended.go index 8b04104..e1db9dc 100644 --- a/gopher/gophermap/extended.go +++ b/gopher/gophermap/extended.go @@ -33,6 +33,8 @@ func ParseExtended(input io.Reader, location *url.URL) (*ExtendedMapDocument, er outer: for num := 1; ; num += 1 { + var item gopher.MapItem + var spl []string line, err := rdr.ReadString('\n') isEOF := errors.Is(err, io.EOF) if err != nil && !isEOF { @@ -48,41 +50,41 @@ outer: Type: CommentType, Display: strings.TrimPrefix(line[1:], " "), }) - continue outer + goto next case '!': doc.Lines = append(doc.Lines, gopher.MapItem{ Type: TitleType, Display: line[1:], }) - continue outer + goto next case '-': doc.Lines = append(doc.Lines, gopher.MapItem{ Type: HiddenType, Selector: line[1:], }) - continue outer + goto next case ':': doc.Lines = append(doc.Lines, gopher.MapItem{ Type: ExtensionType, Display: line[1:], }) - continue outer + goto next case '=': doc.Lines = append(doc.Lines, gopher.MapItem{ Type: InclusionType, Selector: line[1:], }) - continue outer + goto next } } switch line { case "~": doc.Lines = append(doc.Lines, gopher.MapItem{Type: UserListType}) - continue outer + goto next case "%": doc.Lines = append(doc.Lines, gopher.MapItem{Type: VHostListType}) - continue outer + goto next case ".": doc.Lines = append(doc.Lines, gopher.MapItem{Type: EndDocType}) break outer @@ -99,12 +101,12 @@ outer: Hostname: location.Hostname(), Port: location.Port(), }) - continue + goto next } - item := gopher.MapItem{Type: types.Status(line[0])} + item = gopher.MapItem{Type: types.Status(line[0])} - spl := strings.Split(line[1:], "\t") + spl = strings.Split(line[1:], "\t") if len(spl) != 4 { return doc, InvalidLine(num) } @@ -117,6 +119,7 @@ outer: } doc.Lines = append(doc.Lines, item) + next: if isEOF { break } -- cgit v1.2.3