yuin / goldmark

:trophy: A markdown parser written in Go. Easy to extend, standard(CommonMark) compliant, well structured.
MIT License
3.68k stars 255 forks source link

`\x00` panics goldmark #275

Closed Gusted closed 2 years ago

Gusted commented 2 years ago

Please answer the following before submitting your issue:

  1. What version of goldmark are you using? : v1.4.4
  2. What version of Go are you using? : go version devel go1.18-d588f48770 Sat Feb 5 06:14:58 2022 +0000 linux/amd64
  3. What operating system and processor architecture are you using? : Arch Linux + x64
  4. What did you do? : gotip fuzz
  5. What did you expect to see? : Works on input \\\x00\"(strings.NewReader("\\\x00\""))
  6. What did you see instead? : It seems to be a issue with \x00 not currently getting parsed correctly.
    
    panic: runtime error: slice bounds out of range [2:1]

goroutine 144 [running]: github.com/yuin/goldmark/renderer/html.(defaultWriter).Write(0xc0014cfb98?, {0x12644c8, 0xc000787d00}, {0xc00127a000, 0x3, 0x200}) /home/gusted/go/pkg/mod/github.com/yuin/goldmark@v1.4.4/renderer/html/html.go:736 +0xcea github.com/yuin/goldmark/renderer/html.(Renderer).renderText(0xc001476930, {0x12644c8, 0xc000787d00}, {0xc00127a000, 0x3, 0x200}, {0x1271148?, 0xc001238e10}, 0x0?) /home/gusted/go/pkg/mod/github.com/yuin/goldmark@v1.4.4/renderer/html/html.go:610 +0x196 github.com/yuin/goldmark/renderer.(renderer).Render.func2({0x1271148, 0xc001238e10}, 0x80?) /home/gusted/go/pkg/mod/github.com/yuin/goldmark@v1.4.4/renderer/renderer.go:166 +0xf7 github.com/yuin/goldmark/ast.walkHelper({0x1271148, 0xc001238e10}, 0xc0014cfe40) /home/gusted/go/pkg/mod/github.com/yuin/goldmark@v1.4.4/ast/ast.go:492 +0x44 github.com/yuin/goldmark/ast.walkHelper({0x1270de8, 0xc000320a80}, 0xc0014cfe40) /home/gusted/go/pkg/mod/github.com/yuin/goldmark@v1.4.4/ast/ast.go:498 +0x14e github.com/yuin/goldmark/ast.walkHelper({0x12703c8, 0xc001238d80}, 0xc0014cfe40) /home/gusted/go/pkg/mod/github.com/yuin/goldmark@v1.4.4/ast/ast.go:498 +0x14e github.com/yuin/goldmark/ast.Walk(...) /home/gusted/go/pkg/mod/github.com/yuin/goldmark@v1.4.4/ast/ast.go:487 github.com/yuin/goldmark/renderer.(renderer).Render(0xc000788d20?, {0x125ed20?, 0xc0004c1520?}, {0xc00127a000?, 0x3?, 0x200?}, {0x12703c8?, 0xc001238d80?}) /home/gusted/go/pkg/mod/github.com/yuin/goldmark@v1.4.4/renderer/renderer.go:161 +0x2f8 github.com/yuin/goldmark.(*markdown).Convert(0xc0004acf80, {0xc00127a000, 0x3, 0x200}, {0x125ed20, 0xc0004c1520}, {0xc00187d870, 0x1, 0x1}) /home/gusted/go/pkg/mod/github.com/yuin/goldmark@v1.4.4/markdown.go:117 +0x11b


7. Did you confirm your output is different from [CommonMark online demo](https://spec.commonmark.org/dingus/) or other official renderer correspond with an extension?: Yes