devzat icon indicating copy to clipboard operation
devzat copied to clipboard

Crash caught when formting markdown link

Open Arkaeriit opened this issue 2 years ago • 6 comments

I tried to send [](https://xkcd.com/949/) and I got:

        [running]: runtime/debug.Stack()

        ┃ /snap/go/current/src/runtime/debug/stack.go:24 +0x65
        ┃ 

        main.protectFromPanic()

        ┃ /home/ubuntu/devzat/util.go:109 +0x5f
        ┃ 

        panic({0xe50200, 0x17a61a0})

        ┃ /snap/go/current/src/runtime/panic.go:884 +0x213
        ┃ 

        github.com/quackduck/go-term-markdown.(*renderer).RenderNode(0xc0000f0420, {0x1180fe0, 0xc000090000}, {0x118a660?, 0xc000538b60?}, 0x1)

        ┃ /home/ubuntu/go/pkg/mod/github.com/quackduck/[email protected]/renderer.go:310 +0x1381
        ┃ 

        github.com/gomarkdown/markdown.Render.func1({0x118a660?, 0xc000538b60?}, 0x20?)

        ┃ /home/ubuntu/go/pkg/mod/github.com/gomarkdown/[email protected]/markdown.go:63 +0x47
        ┃ 

        github.com/gomarkdown/markdown/ast.NodeVisitorFunc.Visit(0x118a810?, {0x118a660?, 0xc000538b60?}, 0xe0?)

        ┃ /home/ubuntu/go/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:574 +0x2e
        ┃ 

        github.com/gomarkdown/markdown/ast.Walk({0x118a660, 0xc000538b60}, {0x1183760, 0xc000078d60})

        ┃ /home/ubuntu/go/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:546 +0x59
        ┃ 

        github.com/gomarkdown/markdown/ast.Walk({0x118a810, 0xc000131380}, {0x1183760, 0xc000078d60})

        ┃ /home/ubuntu/go/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:557 +0x145
        ┃ 

        github.com/gomarkdown/markdown/ast.Walk({0x118a348, 0xc000131320}, {0x1183760, 0xc000078d60})

        ┃ /home/ubuntu/go/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:557 +0x145
        ┃ 

        github.com/gomarkdown/markdown/ast.WalkFunc(...)

        ┃ /home/ubuntu/go/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:580
        ┃ 

        github.com/gomarkdown/markdown.Render({0x118a348, 0xc000131320}, {0x1187d10, 0xc0000f0420})

        ┃ /home/ubuntu/go/pkg/mod/github.com/gomarkdown/[email protected]/markdown.go:62 +0xd7
        ┃ 

        github.com/quackduck/go-term-markdown.Render({0xc000820ac0, 0x1a}, 0xf4e1c3?, 0x2?, {0x0, 0x0, 0x0})

        ┃ /home/ubuntu/go/pkg/mod/github.com/quackduck/[email protected]/markdown.go:32 +0xbe
        ┃ 

        main.mdRender({0xc000820aa0?, 0x4?}, 0x6, 0xbf)

        ┃ /home/ubuntu/devzat/util.go:134 +0x10f
        ┃

        main.(*User).writeln(0xc00057a900, {0xc00077ee28, 0x13}, {0xc000820aa0, 0x19})

        ┃ /home/ubuntu/devzat/main.go:583 +0x291
        ┃

        main.(*Room).broadcastNoBridges(0x17b05e0, {0xc00077ee28, 0x13}, {0xc000820aa0, 0x19})

        ┃ /home/ubuntu/devzat/main.go:266 +0x125
        ┃

        main.(*Room).broadcast(0x17b05e0?, {0xc00077ee28?, 0x13?}, {0xc000820aa0?, 0x19?})

        ┃ /home/ubuntu/devzat/main.go:217 +0x348
        ┃

        main.runCommands({0xc000820a00?, 0xc000346330?}, 0xc00020e400)

        ┃ /home/ubuntu/devzat/commands.go:121 +0x432
        ┃

        main.(*User).repl(0xc00020e400)

        ┃ /home/ubuntu/devzat/main.go:804 +0x445
        ┃

        main.main.func3({0x1190bd8?, 0xc00029a340})

        ┃ /home/ubuntu/devzat/main.go:152 +0xaf
        ┃

        github.com/gliderlabs/ssh.(*session).handleRequests.func1()

        ┃ /home/ubuntu/go/pkg/mod/github.com/gliderlabs/[email protected]/session.go:261 +0x2d
        ┃

        created by github.com/gliderlabs/ssh.(*session).handleRequests

        ┃ /home/ubuntu/go/pkg/mod/github.com/gliderlabs/[email protected]/session.go:260 +0x51c
        ┃

Arkaeriit avatar May 04 '23 13:05 Arkaeriit

Looks like the error happens on this line in the renderer:

https://github.com/quackduck/go-term-markdown/blob/v0.14.2/renderer.go#LL310C3-L310C3

Very strange

quackduck avatar May 04 '23 14:05 quackduck

Well actually it makes sense right? If you're trying to link something you need to give the link some display text, right?

Of course, a panic is the wrong way to respond to this, but also it doesn't crash the server lol. So we have two options, make the renderer return an error or just don't do anything.

quackduck avatar May 04 '23 14:05 quackduck

Even with a text, the renderer does not changes the output much. I think the render should just display input text in this case.

Arkaeriit avatar May 04 '23 14:05 Arkaeriit

do you mean just the link text?

quackduck avatar May 10 '23 02:05 quackduck

I mean if I type [](http://exmaple.com), the markdown renderer outputs [](http://exmaple.com).

Arkaeriit avatar May 10 '23 11:05 Arkaeriit

What should it output?

quackduck avatar Jul 21 '23 13:07 quackduck

The new markdown engine renders such links very well. Only showing the link.

Arkaeriit avatar Aug 06 '24 12:08 Arkaeriit