divan / gorilla-xmlrpc

Gorilla XML RPC implementation (Golang/Go)
BSD 3-Clause "New" or "Revised" License
69 stars 59 forks source link

DecodeClientResponse fails to parse empty strings #20

Closed jamesfcarter closed 4 years ago

jamesfcarter commented 7 years ago
package main

import (
    "bytes"
    "fmt"
    "github.com/divan/gorilla-xmlrpc/xml"
)

func main() {
    var response struct {
        Result string
    }
    responseXML := []byte("<methodResponse><params><param><value><string></string></value></param></params></methodResponse>")
    err := xml.DecodeClientResponse(bytes.NewBuffer(responseXML), &response)
    if err != nil {
        fmt.Print(err)
    } else {
        fmt.Printf("%s\n", response.Result)
    }
}

I would expect the above to output a blank line but instead it outputs:

<string></string>
divan commented 4 years ago

Fixed in https://github.com/divan/gorilla-xmlrpc/commit/854ddeeec97535a3805f35cd0f049259e5c2e6df