Skip to content

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

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

Closed
quasilyte opened this issue Nov 17, 2021 · 2 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@quasilyte
Copy link
Contributor

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
Contributor

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

@heschi heschi added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 22, 2021
@heschi heschi added this to the Go1.18 milestone Nov 22, 2021
@ianlancetaylor
Copy link
Contributor

Moving milestone to 1.19.

@ianlancetaylor ianlancetaylor modified the milestones: Go1.18, Go1.19 Jan 29, 2022
@golang golang locked and limited conversation to collaborators Mar 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants