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

encoding/xml: "unexpected end element" for autoclosing tags in mixed/upper case #49636

Open
quasilyte opened this issue Nov 17, 2021 · 1 comment
Open
Labels
Milestone

Comments

@quasilyte
Copy link
Contributor

@quasilyte quasilyte commented Nov 17, 2021

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

1.17

Does this issue reproduce with the latest release?

Reproducible on the tip.

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

linux/amd64.

What did you do?

go run example.go (https://play.golang.org/p/sXRjgA-nXoT):

package main

import (
	"fmt"
	"encoding/xml"
	"strings"
)

func main() {
	const input = `<br/><BR/>`
	d := xml.NewDecoder(strings.NewReader(input))
	d.Strict = false
	d.AutoClose = xml.HTMLAutoClose
	d.Entity = xml.HTMLEntity
	for {
		tok, err := d.Token()
		fmt.Printf("%#v\n", tok)
		if err != nil {
			fmt.Printf("err: %v\n", err)
			break
		}
	}
}

What did you expect to see?

xml.StartElement{Name:xml.Name{Space:"", Local:"br"}, Attr:[]xml.Attr{}}
xml.EndElement{Name:xml.Name{Space:"", Local:"br"}}
xml.StartElement{Name:xml.Name{Space:"", Local:"BR"}, Attr:[]xml.Attr{}}
xml.EndElement{Name:xml.Name{Space:"", Local:"BR"}}
<nil>
err: EOF

Note: no syntax errors.

What did you see instead?

xml.StartElement{Name:xml.Name{Space:"", Local:"br"}, Attr:[]xml.Attr{}}
xml.EndElement{Name:xml.Name{Space:"", Local:"br"}}
xml.StartElement{Name:xml.Name{Space:"", Local:"BR"}, Attr:[]xml.Attr{}}
xml.EndElement{Name:xml.Name{Space:"", Local:"BR"}}
<nil>
err: XML syntax error on line 1: unexpected end element </BR>
@gopherbot
Copy link

@gopherbot gopherbot commented Nov 17, 2021

Change https://golang.org/cl/364734 mentions this issue: encoding/xml: improve the test coverage, fix minor bugs

Loading

@heschi heschi added this to the Go1.18 milestone Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants