Skip to content

Bad href attribute when linkify and typographer extensions are enabled #335

@jmooring

Description

@jmooring

What version of goldmark are you using? : 1.5.2
What version of Go are you using? : 1.19.3
What operating system and processor architecture are you using? : linux/amd64

code
package main

import (
	"bytes"
	"fmt"

	"github.com/yuin/goldmark"
	"github.com/yuin/goldmark/extension"
)

func main() {
	md := goldmark.New(
		goldmark.WithExtensions(
			extension.Typographer,
			extension.Linkify,
		),
	)

	input := `"https://example.org/"`

	var buf bytes.Buffer
	if err := md.Convert([]byte(input), &buf); err != nil {
		panic(err)
	}

	fmt.Println(buf.String())

}

Expected output:

<p>&ldquo;<a href="https://example.org/">https://example.org/</a>&rdquo;</p>

Actual output:

<p>&ldquo;<a href="https://example.org/%22">https://example.org/&quot;</a></p>

The behavior is triggered by the trailing slash in the URL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    pinnedissue should not be closed by stalebot

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions