mirror of
https://github.com/golang/go
synced 2024-11-12 08:20:22 -07:00
encoding/xml: fix spurious "no semicolon" in error
Noticed while doing other XML investigations. R=golang-dev, r CC=golang-dev https://golang.org/cl/7550045
This commit is contained in:
parent
aa81eb5901
commit
019754ed40
@ -956,7 +956,7 @@ Input:
|
||||
b0, b1 = 0, 0
|
||||
continue Input
|
||||
}
|
||||
ent := string(d.buf.Bytes()[before])
|
||||
ent := string(d.buf.Bytes()[before:])
|
||||
if ent[len(ent)-1] != ';' {
|
||||
ent += " (no semicolon)"
|
||||
}
|
||||
|
@ -595,13 +595,6 @@ func TestEntityInsideCDATA(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The last three tests (respectively one for characters in attribute
|
||||
// names and two for character entities) pass not because of code
|
||||
// changed for issue 1259, but instead pass with the given messages
|
||||
// from other parts of xml.Decoder. I provide these to note the
|
||||
// current behavior of situations where one might think that character
|
||||
// range checking would detect the error, but it does not in fact.
|
||||
|
||||
var characterTests = []struct {
|
||||
in string
|
||||
err string
|
||||
@ -611,8 +604,10 @@ var characterTests = []struct {
|
||||
{"\xef\xbf\xbe<doc/>", "illegal character code U+FFFE"},
|
||||
{"<?xml version=\"1.0\"?><doc>\r\n<hiya/>\x07<toots/></doc>", "illegal character code U+0007"},
|
||||
{"<?xml version=\"1.0\"?><doc \x12='value'>what's up</doc>", "expected attribute name in element"},
|
||||
{"<doc>&abc\x01;</doc>", "invalid character entity &abc (no semicolon)"},
|
||||
{"<doc>&\x01;</doc>", "invalid character entity & (no semicolon)"},
|
||||
{"<doc>&\xef\xbf\xbe;</doc>", "invalid character entity & (no semicolon)"},
|
||||
{"<doc>&\xef\xbf\xbe;</doc>", "invalid character entity &\uFFFE;"},
|
||||
{"<doc>&hello;</doc>", "invalid character entity &hello;"},
|
||||
}
|
||||
|
||||
func TestDisallowedCharacters(t *testing.T) {
|
||||
@ -629,7 +624,7 @@ func TestDisallowedCharacters(t *testing.T) {
|
||||
t.Fatalf("input %d d.Token() = _, %v, want _, *SyntaxError", i, err)
|
||||
}
|
||||
if synerr.Msg != tt.err {
|
||||
t.Fatalf("input %d synerr.Msg wrong: want '%s', got '%s'", i, tt.err, synerr.Msg)
|
||||
t.Fatalf("input %d synerr.Msg wrong: want %q, got %q", i, tt.err, synerr.Msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user