~samwhited/xmpp

5d57749d8be273218a5cccd0864678e96891abf8 — Sam Whited 9 months ago d99cc4f
component: only check stream ID if not an error

This fixes an error where the stream ID wasn't set on Prosody unless the
stream would be used. While I think Prosody is in the wrong here, their
behavior likely won't cause any problems so it doesn't hurt us to mimic
it for compatibility as long as we still maintain the check on streams
that will be used.

Signed-off-by: Sam Whited <sam@samwhited.com>
2 files changed, 5 insertions(+), 4 deletions(-)

M CHANGELOG.md
M component/component.go
M CHANGELOG.md => CHANGELOG.md +2 -0
@@ 47,6 47,8 @@ All notable changes to this project will be documented in this file.

### Fixed

- component: the wrong error is no longer returned if Prosody sends an error
  immediately after the start of a stream with no ID
- dial: dialing an XMPP connection where no xmpps SRV records exist no longer
  results in an error (fallback works correctly)
- roster: fix infinite loop marshaling lists of items

M component/component.go => component/component.go +3 -4
@@ 98,10 98,6 @@ func Negotiator(addr jid.JID, secret []byte, recv bool) xmpp.Negotiator {
			}
		}

		if id == "" {
			return mask, nil, nil, errors.New("Expected server stream to contain stream ID")
		}

		/* #nosec */
		h := sha1.New()



@@ 132,6 128,9 @@ func Negotiator(addr jid.JID, secret []byte, recv bool) xmpp.Negotiator {
		case "error":
			return mask, nil, nil, stream.NotAuthorized
		case "handshake":
			if id == "" {
				return mask, nil, nil, errors.New("component: expected server stream to contain stream ID")
			}
			err = d.Skip()
			return xmpp.Ready | xmpp.Authn, nil, nil, err
		}