Giter Club home page Giter Club logo

Comments (5)

mattn avatar mattn commented on July 28, 2024

If you can reproduce this, Could you please try this?

diff --git a/xmpp.go b/xmpp.go
index e20b57a..04d377c 100644
--- a/xmpp.go
+++ b/xmpp.go
@@ -406,7 +406,7 @@ func (c *Client) init(o *Options) error {
 	case *saslFailure:
 		// v.Any is type of sub-element in failure,
 		// which gives a description of what failed.
-		return errors.New("auth failure: " + v.Any.Local)
+		return errors.New("auth failure: " + v.Text)
 	default:
 		return errors.New("expected <success> or <failure>, got <" + name.Local + "> in " + name.Space)
 	}
@@ -698,7 +698,8 @@ type saslSuccess struct {
 
 type saslFailure struct {
 	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl failure"`
-	Any     xml.Name `xml:",any"`
+	Any     xml.Name
+	Text    string
 }
 
 // RFC 3920  C.5  Resource binding name space

from go-xmpp.

froodian avatar froodian commented on July 28, 2024

Hi @mattn, thanks for the quick response! The diff you provided didn't quite work for me, but this does work (added xml:"text" for it to correctly find the text element, and did a fallback to v.Any.Local if that doesn't exist, so that auth-failure messages still get returned properly)

diff --git a/xmpp.go b/xmpp.go
index e20b57a..04d377c 100644
--- a/xmpp.go
+++ b/xmpp.go
@@ -406,7 +406,7 @@ func (c *Client) init(o *Options) error {
 	case *saslFailure:
+		errorMessage := v.Text
+		if errorMessage == "" {
			// v.Any is type of sub-element in failure,
-			// which gives a description of what failed.
+			// which gives a description of what failed if there was no text element
+			errorMessage = v.Any.Local
+		}
-		return errors.New("auth failure: " + v.Any.Local)
+		return errors.New("auth failure: " + errorMessage)
 	default:
 		return errors.New("expected <success> or <failure>, got <" + name.Local + "> in " + name.Space)
 	}
@@ -698,7 +698,8 @@ type saslSuccess struct {
 
 type saslFailure struct {
 	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl failure"`
	Any     xml.Name `xml:",any"`
+	Text    string   `xml:"text"`
 }
 
 // RFC 3920  C.5  Resource binding name space

from go-xmpp.

mattn avatar mattn commented on July 28, 2024

Thanks. Could you please send me the diff as p-r?

from go-xmpp.

froodian avatar froodian commented on July 28, 2024

Sure thing! https://github.com/mattn/go-xmpp/pull/81/files

from go-xmpp.

froodian avatar froodian commented on July 28, 2024

Closing as this was fixed by the above pull

from go-xmpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.