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: mismatching namespace error misses a space char #49635

Closed
quasilyte opened this issue Nov 17, 2021 · 2 comments
Closed

encoding/xml: mismatching namespace error misses a space char #49635

quasilyte opened this issue Nov 17, 2021 · 2 comments
Labels
Documentation 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/dU4NQ2vTVyF):

package main

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

func main() {
	const input = `<a:foo></b:foo>`
	d := xml.NewDecoder(strings.NewReader(input))
	d.Token() // read StartElement
	_, err := d.Token() // read EndElement
	fmt.Println(err)
}

What did you expect to see?

XML syntax error on line 1: element <foo> in space a closed by </foo> in space b

What did you see instead?

XML syntax error on line 1: element <foo> in space aclosed by </foo> in space b

Note the diff:

- XML syntax error on line 1: element <foo> in space aclosed by </foo> in space b
+ XML syntax error on line 1: element <foo> in space a closed by </foo> in space b
@gopherbot
Copy link

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

@seankhliao seankhliao added Documentation NeedsFix The path to resolution is known, but the work has not been done. labels Nov 17, 2021
@quasilyte
Copy link
Contributor Author

Could be a duplicate of #48890.
I'm closing this one in favor of the issue that was opened earlier.

gopherbot pushed a commit that referenced this issue Mar 4, 2022
Improve the test coverage of encoding/xml package by adding
the test cases for the execution paths that were not covered before.

Since it reveals a couple of issues, fix them as well while we're at it.

As I used an `strings.EqualFold` instead of adding one more `strings.ToLower`,
our fix to `autoClose()` tends to run faster as well as a result.

	name             old time/op    new time/op    delta
	HTMLAutoClose-8    5.93µs ± 2%    5.75µs ± 3%  -3.16%  (p=0.000 n=10+10)
	name             old alloc/op   new alloc/op   delta
	HTMLAutoClose-8    2.60kB ± 0%    2.58kB ± 0%  -0.46%  (p=0.000 n=10+10)
	name             old allocs/op  new allocs/op  delta
	HTMLAutoClose-8      72.0 ± 0%      67.0 ± 0%  -6.94%  (p=0.000 n=10+10)

The overall `encoding/xml` test coverage increase is `88.1% -> 89.9%`;
although it may look insignificant, this CL covers some important corner cases,
like `autoClose()` functionality (that was not tested at all).

Fixes #49635
Fixes #49636

Change-Id: I50b2769896c197eb285672313b7148f4fe8bdb38
Reviewed-on: https://go-review.googlesource.com/c/go/+/364734
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
@dmitshur dmitshur added this to the Go1.19 milestone Mar 7, 2022
@golang golang locked and limited conversation to collaborators Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation 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