From 2176147dec133677cec0bb4fcc5ebdb604e4ae75 Mon Sep 17 00:00:00 2001 From: Azareal Date: Thu, 18 Feb 2021 23:02:54 +1000 Subject: [PATCH] fix parser tests expand parser tests --- common/parser.go | 2 +- parser_test.go | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/parser.go b/common/parser.go index 2c074223..90a5b921 100644 --- a/common/parser.go +++ b/common/parser.go @@ -633,7 +633,7 @@ func ParseMessage2(msg string, sectionID int, sectionType string, settings *Pars case 'h', 'f', 'g', '/': //fmt.Println("s3") fch := msg[i+1] - if len(msg) > i+5 && fch == 't' && msg[i+2] == 't' && msg[i+3] == 'p' { + if fch == 't' && len(msg) > i+5 && msg[i+2] == 't' && msg[i+3] == 'p' { if len(msg) > i+6 && msg[i+4] == 's' && msg[i+5] == ':' && msg[i+6] == '/' { // Do nothing } else if msg[i+4] == ':' && msg[i+5] == '/' { diff --git a/parser_test.go b/parser_test.go index c7f2f5ca..6284a9cc 100644 --- a/parser_test.go +++ b/parser_test.go @@ -192,9 +192,21 @@ func TestParser(t *testing.T) { l.Add("git:// ", "[Invalid URL] ") l.Add("ssh:// ", "ssh:// ") + l.Add("//t", "t") l.Add("// t", "// t") l.Add("http:// t", "[Invalid URL] t") + l.Add("g", "g") + l.Add("g/", "//") // todo: fix this + l.Add("/g", "/g") + l.Add("/gg", "/gg") + l.Add("/g/", "/g/") + l.Add("hi", "hi") + l.Add("hit", "hit") + l.Add("hit:", "hit:") + l.Add("hit:/", "/") // todo: fix this + l.Add("hit://", "") // todo: fix this + l.Add("hit://t", "t") // todo: fix this l.Add("h", "h") l.Add("ht", "ht") l.Add("htt", "htt") @@ -242,7 +254,7 @@ func TestParser(t *testing.T) { //l.Add("//"+url+"//"+url, eurl+""+eurl) //l.Add("//"+url+"|//"+url, eurl+"|"+eurl) l.Add("//"+url+"|//"+url, "[Invalid URL]|//"+url) - l.Add("//"+url+"//"+url, "" + url +"//"+url+ "") + l.Add("//"+url+"//"+url, ""+url+"//"+url+"") l.Add("//"+url+"\n\n//"+url, eurl+"

"+eurl) pre2 := c.Config.SslSchema @@ -376,6 +388,7 @@ func TestParser(t *testing.T) { l.Add("@-1", "[Invalid Profile]1") // TODO: Fix this hack and make the results a bit more reproducible, push the tests further in the process. + c.GuestUser.Perms.AutoLink = true for _, item := range l.Items { if res := c.ParseMessage(item.Msg, 1, "forums", nil, nil); res != item.Expects { if item.Name != "" {