From 2e964cc5862e774b82bfea915cad112da17101ea Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 29 Aug 2019 16:51:36 -0700 Subject: [PATCH 1/2] Fixes issue where type 7 response still queries for search. --- gopher/gopher.go | 3 +++ gopher/view.go | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gopher/gopher.go b/gopher/gopher.go index 41cca9a..21b7d02 100644 --- a/gopher/gopher.go +++ b/gopher/gopher.go @@ -95,6 +95,9 @@ func Visit(addr, openhttp string) (View, error) { return View{}, fmt.Errorf("") } + } else if u.Gophertype == "7" && strings.Contains(u.Resource, "\t") { + u.Gophertype = "1" + u.Full = u.Scheme + "://" + u.Host + ":" + u.Port + "/" + u.Gophertype + u.Resource } text, err := Retrieve(u) diff --git a/gopher/view.go b/gopher/view.go index 3afb745..813f4ca 100644 --- a/gopher/view.go +++ b/gopher/view.go @@ -46,9 +46,8 @@ func (v *View) ParseMap() { } else { title = "" } - if len(line[0]) > 0 && string(line[0][0]) == "i" { + if len(line) > 1 && len(line[0]) > 0 && string(line[0][0]) == "i" { v.Content[i] = " " + string(title) - continue } else if len(line) >= 4 { fulllink := fmt.Sprintf("%s:%s/%s%s", line[2], line[3], string(line[0][0]), line[1]) v.Links = append(v.Links, fulllink) From bfa8a162e3ed13e5a2cea48e431fea10e0848df4 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Fri, 30 Aug 2019 19:50:52 -0700 Subject: [PATCH 2/2] Simplified gophertype fix for search response --- gopher/gopher.go | 5 +---- gopher/url.go | 5 +++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gopher/gopher.go b/gopher/gopher.go index 21b7d02..82bedea 100644 --- a/gopher/gopher.go +++ b/gopher/gopher.go @@ -95,10 +95,7 @@ func Visit(addr, openhttp string) (View, error) { return View{}, fmt.Errorf("") } - } else if u.Gophertype == "7" && strings.Contains(u.Resource, "\t") { - u.Gophertype = "1" - u.Full = u.Scheme + "://" + u.Host + ":" + u.Port + "/" + u.Gophertype + u.Resource - } + } text, err := Retrieve(u) if err != nil { diff --git a/gopher/url.go b/gopher/url.go index cb80f2a..c94f020 100644 --- a/gopher/url.go +++ b/gopher/url.go @@ -3,6 +3,7 @@ package gopher import ( "errors" "regexp" + "strings" ) //------------------------------------------------\\ @@ -76,6 +77,10 @@ func MakeUrl(u string) (Url, error) { out.Gophertype = "0" } + if out.Gophertype == "7" && strings.Contains(out.Resource, "\t") { + out.Gophertype = "1" + } + switch out.Gophertype { case "1", "0", "h", "7": out.IsBinary = false