Skip to content
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

crash during renderFencedCodeBlock #229

Closed
rsc opened this issue Jun 28, 2021 · 1 comment
Closed

crash during renderFencedCodeBlock #229

rsc opened this issue Jun 28, 2021 · 1 comment

Comments

@rsc
Copy link

rsc commented Jun 28, 2021

Please answer the following before submitting your issue:

  1. What version of goldmark are you using? : v1.3.8

  2. What version of Go are you using? : Go 1.17 devel branch

  3. What operating system and processor architecture are you using? : macOS x86

  4. What did you do? : Render the following input:

    - List
    
        ```
        A
        	B
        C
        ```
    

    The entire fenced code block is indented with four leading spaces at the start of each line.
    The B line has a tab immediately before the B. That is, that line is "space space space space tab B newline".

  5. What did you expect to see? : Rendered HTML.

  6. What did you see instead? : A crash.

    panic: runtime error: slice bounds out of range [32:29]
    
    github.com/yuin/goldmark/text.(*Segment).Value(0xc00030d0c8, {0xc000348210, 0xc00052f200, 0x2d})
    	/Users/rsc/pkg/mod/github.com/yuin/goldmark@v1.3.8/text/segment.go:48 +0x29d
    github.com/yuin/goldmark/renderer/html.(*Renderer).writeLines(0xc00052c9d8, {0x1983b90, 0xc00052f200}, {0xc000348210, 0x2c, 0x2d}, {0x19921f0, 0xc000490500})
    	/Users/rsc/pkg/mod/github.com/yuin/goldmark@v1.3.8/renderer/html/html.go:193 +0xbb
    github.com/yuin/goldmark/renderer/html.(*Renderer).renderFencedCodeBlock(0xc00052c9d8, {0x1983b90, 0xc00052f200}, {0xc000348210, 0x2c, 0x2d}, {0x19921f0, 0xc000490500}, 0x90)
    	/Users/rsc/pkg/mod/github.com/yuin/goldmark@v1.3.8/renderer/html/html.go:285 +0x18b
    github.com/yuin/goldmark/renderer.(*renderer).Render.func2({0x19921f0, 0xc000490500}, 0x1)
    	/Users/rsc/pkg/mod/github.com/yuin/goldmark@v1.3.8/renderer/renderer.go:166 +0xd1
    github.com/yuin/goldmark/ast.walkHelper({0x19921f0, 0xc000490500}, 0xc00030d370)
    	/Users/rsc/pkg/mod/github.com/yuin/goldmark@v1.3.8/ast/ast.go:492 +0x34
    github.com/yuin/goldmark/ast.walkHelper({0x19928b0, 0xc00056c750}, 0xc00030d370)
    	/Users/rsc/pkg/mod/github.com/yuin/goldmark@v1.3.8/ast/ast.go:498 +0x8e
    github.com/yuin/goldmark/ast.walkHelper({0x1992790, 0xc00056c6c0}, 0xc00030d370)
    	/Users/rsc/pkg/mod/github.com/yuin/goldmark@v1.3.8/ast/ast.go:498 +0x8e
    github.com/yuin/goldmark/ast.walkHelper({0x1991fb0, 0xc00056c630}, 0xc00030d370)
    	/Users/rsc/pkg/mod/github.com/yuin/goldmark@v1.3.8/ast/ast.go:498 +0x8e
    github.com/yuin/goldmark/ast.Walk(...)
    	/Users/rsc/pkg/mod/github.com/yuin/goldmark@v1.3.8/ast/ast.go:487
    github.com/yuin/goldmark/renderer.(*renderer).Render(0xc00049a320, {0x19637a0, 0xc0008eb770}, {0xc000348210, 0x2c, 0x2d}, {0x1991fb0, 0xc00056c630})
    	/Users/rsc/pkg/mod/github.com/yuin/goldmark@v1.3.8/renderer/renderer.go:161 +0x22d
    github.com/yuin/goldmark.(*markdown).Convert(0xc00052ee40, {0xc000348210, 0x2c, 0x2d}, {0x19637a0, 0xc0008eb770}, {0x0, 0x0, 0x0})
    	/Users/rsc/pkg/mod/github.com/yuin/goldmark@v1.3.8/markdown.go:117 +0x10b
    
  7. Did you confirm your output is different from CommonMark online demo or other official renderer correspond with an extension? : No, but it would be truly astonishing if the official renderer did this too.

@yuin yuin closed this as completed in 759cc35 Jun 28, 2021
@rsc
Copy link
Author

rsc commented Jun 28, 2021

Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant