mirror of
https://github.com/golang/go
synced 2024-11-25 00:07:56 -07:00
encoding/xml: require whitespace before processing instruction value
The value of a processing instruction must either be empty or have whitespace before it. Fixes: #68386
This commit is contained in:
parent
239666cd73
commit
9c648caab3
@ -604,14 +604,20 @@ func (d *Decoder) rawToken() (Token, error) {
|
|||||||
case '?':
|
case '?':
|
||||||
// <?: Processing instruction.
|
// <?: Processing instruction.
|
||||||
var target string
|
var target string
|
||||||
|
var data []byte
|
||||||
if target, ok = d.name(); !ok {
|
if target, ok = d.name(); !ok {
|
||||||
if d.err == nil {
|
if d.err == nil {
|
||||||
d.err = d.syntaxError("expected target name after <?")
|
d.err = d.syntaxError("expected target name after <?")
|
||||||
}
|
}
|
||||||
return nil, d.err
|
return nil, d.err
|
||||||
}
|
}
|
||||||
d.space()
|
|
||||||
d.buf.Reset()
|
d.buf.Reset()
|
||||||
|
if b, ok = d.mustgetc(); !ok {
|
||||||
|
return nil, d.err
|
||||||
|
}
|
||||||
|
switch b {
|
||||||
|
case ' ', '\t', '\r', '\n':
|
||||||
|
d.space()
|
||||||
var b0 byte
|
var b0 byte
|
||||||
for {
|
for {
|
||||||
if b, ok = d.mustgetc(); !ok {
|
if b, ok = d.mustgetc(); !ok {
|
||||||
@ -623,8 +629,20 @@ func (d *Decoder) rawToken() (Token, error) {
|
|||||||
}
|
}
|
||||||
b0 = b
|
b0 = b
|
||||||
}
|
}
|
||||||
data := d.buf.Bytes()
|
data = d.buf.Bytes()
|
||||||
data = data[0 : len(data)-2] // chop ?>
|
data = data[0 : len(data)-2] // chop ?>
|
||||||
|
case '?':
|
||||||
|
if b, ok = d.mustgetc(); !ok {
|
||||||
|
return nil, d.err
|
||||||
|
}
|
||||||
|
if b != '>' {
|
||||||
|
d.err = d.syntaxError("expected ?> after empty processing instruction")
|
||||||
|
return nil, d.err
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
d.err = d.syntaxError("unexpected byte after processing instruction name")
|
||||||
|
return nil, d.err
|
||||||
|
}
|
||||||
|
|
||||||
if target == "xml" {
|
if target == "xml" {
|
||||||
content := string(data)
|
content := string(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user