Permalink
Browse files

Escape soapLogin credentials

vsphere client doesn't escape password correctly and that leads to an obscure error:
> Error returnet by expat parser: not well-formed (invalid token)
  • Loading branch information...
1 parent 6c2eb6d commit 197933223b1e7d34a934148b8f78b60f95fc93d5 @simnv simnv committed Feb 22, 2016
Showing with 5 additions and 1 deletion.
  1. +5 −1 vsphere/vsphere.go
View
@@ -55,7 +55,11 @@ func Connect(host, user, pwd string) (*Vsphere, error) {
if uuid.UUID == "" {
return nil, fmt.Errorf("vsphere: no UUID during connect")
}
- if err := v.call(fmt.Sprintf(soapLogin, user, pwd), nil); err != nil {
+ userbuf := new(bytes.Buffer)
+ pwdbuf := new(bytes.Buffer)
+ xml.EscapeText(userbuf, []byte(user))
+ xml.EscapeText(pwdbuf, []byte(pwd))
+ if err := v.call(fmt.Sprintf(soapLogin, userbuf, pwdbuf), nil); err != nil {
return nil, err
}
return v, nil

0 comments on commit 1979332

Please sign in to comment.