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

x/net/html: cryptic error - void element has child nodes #50095

Open
mihaiav opened this issue Dec 10, 2021 · 0 comments
Open

x/net/html: cryptic error - void element has child nodes #50095

mihaiav opened this issue Dec 10, 2021 · 0 comments
Labels
NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@mihaiav
Copy link

mihaiav commented Dec 10, 2021

What version of Go are you using (go version)?

$ go version
 go1.17.2 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
MacOS/intel

What did you do?

package main

import (
    "golang.org/x/net/html"
    "io/ioutil"
    "strings"
)

func main() {
    nodes, err := html.ParseFragment(strings.NewReader("<svg ><link class="hello-class" >0"), nil)
    if err != nil {
        return
    }
    for _, n := range nodes {
        if err := html.Render(ioutil.Discard, n); err != nil {
            panic(err)
        }
    }
}

What did you expect to see?

HTML documents are usually long and such an cryptic error is hard to debug. I expected at least an error that points to the specific errornous node. The error should include the attributes of the invalid node and perhaps 2 - 3 parent nodes as well.

What did you see instead?

panic: html: void element <link> has child nodes

A cryptic error that provides little help.

This is also related to #10535

@gopherbot gopherbot added this to the Unreleased milestone Dec 10, 2021
@toothrot toothrot added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

3 participants