mirror of
https://github.com/golang/go
synced 2024-11-02 11:50:30 +00:00
xml: allow parsing of <_> </_>.
R=rsc, nigeltao CC=golang-dev https://golang.org/cl/5298061
This commit is contained in:
parent
ad0e8b31d8
commit
1371ac2f0b
2 changed files with 11 additions and 2 deletions
|
@ -201,8 +201,8 @@ func (p *Parser) Unmarshal(val interface{}, start *StartElement) error {
|
|||
func fieldName(original string) string {
|
||||
|
||||
var i int
|
||||
//remove leading underscores
|
||||
for i = 0; i < len(original) && original[i] == '_'; i++ {
|
||||
//remove leading underscores, without exhausting all characters
|
||||
for i = 0; i < len(original)-1 && original[i] == '_'; i++ {
|
||||
}
|
||||
|
||||
return strings.Map(
|
||||
|
|
|
@ -245,6 +245,9 @@ const pathTestString = `
|
|||
<Value>C</Value>
|
||||
<Value>D</Value>
|
||||
</Item1>
|
||||
<_>
|
||||
<value>E</value>
|
||||
</_>
|
||||
</items>
|
||||
<after>2</after>
|
||||
</result>
|
||||
|
@ -279,11 +282,17 @@ type PathTestD struct {
|
|||
Before, After string
|
||||
}
|
||||
|
||||
type PathTestE struct {
|
||||
Underline string `xml:"items>_>value"`
|
||||
Before, After string
|
||||
}
|
||||
|
||||
var pathTests = []interface{}{
|
||||
&PathTestA{Items: []PathTestItem{{"A"}, {"D"}}, Before: "1", After: "2"},
|
||||
&PathTestB{Other: []PathTestItem{{"A"}, {"D"}}, Before: "1", After: "2"},
|
||||
&PathTestC{Values1: []string{"A", "C", "D"}, Values2: []string{"B"}, Before: "1", After: "2"},
|
||||
&PathTestD{Other: PathTestSet{Item1: []PathTestItem{{"A"}, {"D"}}}, Before: "1", After: "2"},
|
||||
&PathTestE{Underline: "E", Before: "1", After: "2"},
|
||||
}
|
||||
|
||||
func TestUnmarshalPaths(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue