File tree 2 files changed +25
-9
lines changed
2 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -794,13 +794,30 @@ func (d *Decoder) rawToken() (Token, error) {
794
794
}
795
795
796
796
attr = []Attr {}
797
- for {
798
- d .space ()
797
+ Outer: for {
799
798
if b , ok = d .mustgetc (); ! ok {
800
799
return nil , d .err
801
800
}
802
- if b == '/' {
801
+ switch b {
802
+ case ' ' , '\t' , '\r' , '\n' :
803
+ // Skip subsequent spaces
804
+ d .space ()
805
+ if b , ok = d .mustgetc (); ! ok {
806
+ return nil , d .err
807
+ }
808
+ if b == '>' {
809
+ break Outer
810
+ }
811
+ empty = b == '/'
812
+ case '>' :
813
+ break Outer
814
+ case '/' :
803
815
empty = true
816
+ default :
817
+ d .err = d .syntaxError ("expected whitespace, />, or > following element name or attribute value" )
818
+ return nil , d .err
819
+ }
820
+ if empty {
804
821
if b , ok = d .mustgetc (); ! ok {
805
822
return nil , d .err
806
823
}
@@ -810,9 +827,6 @@ func (d *Decoder) rawToken() (Token, error) {
810
827
}
811
828
break
812
829
}
813
- if b == '>' {
814
- break
815
- }
816
830
d .ungetc (b )
817
831
818
832
a := Attr {}
Original file line number Diff line number Diff line change @@ -265,6 +265,8 @@ var xmlInput = []string{
265
265
"<t a>" ,
266
266
"<t a=>" ,
267
267
"<t a=v>" ,
268
+ // Issue 68385
269
+ "<a b='c'c='d'/>" ,
268
270
// "<![CDATA[d]]>", // let the Token() caller handle
269
271
"<t></e>" ,
270
272
"<t></>" ,
@@ -1122,15 +1124,15 @@ func TestIssue7113(t *testing.T) {
1122
1124
}
1123
1125
1124
1126
func TestIssue20396 (t * testing.T ) {
1125
-
1126
- var attrError = UnmarshalError ("XML syntax error on line 1: expected attribute name in element" )
1127
+ var attrError = UnmarshalError ("XML syntax error on line 1: expected whitespace, />, or > following element name or attribute value" )
1127
1128
1128
1129
testCases := []struct {
1129
1130
s string
1130
1131
wantErr error
1131
1132
}{
1132
1133
{`<a:te:st xmlns:a="abcd"/>` , // Issue 20396
1133
- UnmarshalError ("XML syntax error on line 1: expected element name after <" )},
1134
+ UnmarshalError ("XML syntax error on line 1: colon after prefixed XML name a:te" )},
1135
+ {`<a test='d'xmlns:a="abcd"/>` , attrError },
1134
1136
{`<a:te=st xmlns:a="abcd"/>` , attrError },
1135
1137
{`<a:te&st xmlns:a="abcd"/>` , attrError },
1136
1138
{`<a:test xmlns:a="abcd"/>` , nil },
You can’t perform that action at this time.
0 commit comments