-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
renderer: fix panic on unregistered node kind #299
base: master
Are you sure you want to change the base?
Conversation
Renderers can ignore nodes they aren't interested in. However when a renderer doesn't register the highest node kind traversing a Markdown document results in the following panic: panic: runtime error: index out of range [1] with length 1 goroutine 1 [running]: github.com/yuin/goldmark/renderer.(*renderer).Render.func2({0x9d8630, 0xc0001237a0}, 0x40?) /home/simon/go/pkg/mod/github.com/yuin/[email protected]/renderer/renderer.go:164 +0xd9 github.com/yuin/goldmark/ast.walkHelper({0x9d8630, 0xc0001237a0}, 0xc000521a48) /home/simon/go/pkg/mod/github.com/yuin/[email protected]/ast/ast.go:492 +0x34 github.com/yuin/goldmark/ast.Walk(...) /home/simon/go/pkg/mod/github.com/yuin/[email protected]/ast/ast.go:487 github.com/yuin/goldmark/renderer.(*renderer).Render(0xc0002d80a0?, {0x9d3b60?, 0xc0000744a0?}, {0xc0002f4580?, 0x281?, 0x2c0?}, {0x9d8630?, 0xc0001237a0?}) /home/simon/go/pkg/mod/github.com/yuin/[email protected]/renderer/renderer.go:161 +0x225 github.com/yuin/goldmark.(*markdown).Convert(0xc0001e1d40, {0xc0002f4580, 0x281, 0x2c0}, {0x9d3b60, 0xc0000744a0}, {0x0, 0x0, 0x0}) /home/simon/go/pkg/mod/github.com/yuin/[email protected]/markdown.go:117 +0x10b main.renderMarkdown({0xc0002f42c0, 0x281}) /home/simon/src/hut/markdown.go:16 +0x97 main.newListsListCommand.func1(0xc000270280?, {0xc778b8, 0x0, 0x0?}) /home/simon/src/hut/lists.go:109 +0x2ee github.com/spf13/cobra.(*Command).execute(0xc000270280, {0xc778b8, 0x0, 0x0}) /home/simon/go/pkg/mod/github.com/spf13/[email protected]/command.go:860 +0x663 github.com/spf13/cobra.(*Command).ExecuteC(0xc000242c80) /home/simon/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x3b4 github.com/spf13/cobra.(*Command).Execute(...) /home/simon/go/pkg/mod/github.com/spf13/[email protected]/command.go:902 github.com/spf13/cobra.(*Command).ExecuteContext(...) /home/simon/go/pkg/mod/github.com/spf13/[email protected]/command.go:895 main.main() /home/simon/src/hut/main.go:49 +0x30b Make sure r.nodeRendererFuncs is large enough before trying to access it.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Ping |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Ping |
@yuin any chance to get this reviewed? |
I was about to write a new bug report for this. So ping! from me too. |
FWIW, this has come up before. #107 made a similar change to this PR, removing the panic, but the behavior change was considered undesirable. Following that, #110 and #166 made a variant of the change that kept the panic but improved the error message. @yuin, would you be open to merging the message change? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Ping |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
. |
This PR is stale because it has been open for 180 days with no activity. |
. |
This PR is stale because it has been open for 180 days with no activity. |
. |
e7e4266
to
a590622
Compare
Renderers can ignore nodes they aren't interested in. However when a
renderer doesn't register the highest node kind traversing a Markdown
document results in the following panic:
Make sure r.nodeRendererFuncs is large enough before trying to access it.
Workaround without this patch: