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

Incorrectly escapes HTML in output #100

Closed frioux closed 4 years ago

frioux commented 4 years ago
  1. What version of goldmark are you using? : v1.1.22
  2. What version of Go are you using? : 1.13.4
  3. What operating system and processor architecture are you using? : Linux, x86_64
  4. What did you do? : Tried to render a link with html in it (* <img ...>)
  5. What did you expect to see? : an image
  6. What did you see instead? : raw html
  7. Did you confirm your output is different from CommonMark online demo or other official renderer correspond with an extension?: yes

Here's a full repro:

package main

import (
        "fmt"
        "os"

        "github.com/yuin/goldmark"
        "github.com/yuin/goldmark/parser"
        "github.com/yuin/goldmark/renderer/html"
)

func main() {
        gold := goldmark.New(
                goldmark.WithParserOptions(
                        parser.WithAutoHeadingID(),
                ),
                goldmark.WithRendererOptions(
                        html.WithUnsafe(),
                ),
        )

        if err := gold.Convert([]byte(` * <img href="doesntmatter.jpg />"`), os.Stdout); err != nil {
                fmt.Println(err)
                os.Exit(1)
        }
}

If you can point out where to look I am interested in trying to help fix this.

yuin commented 4 years ago

You might have just making a typo.

 * <img href="doesntmatter.jpg />"

to

 * <img href="doesntmatter.jpg" />

works for me.

frioux commented 4 years ago

Thank you; that's embarrassing, but I guess the best outcome anyway! ;)