vukoye / xmpp_dart

Lightweight XMPP client library written in Dart
Apache License 2.0
83 stars 64 forks source link

Connection#handleResponse do not handle descendents nodes anymore #89

Closed tanukijs closed 1 year ago

tanukijs commented 1 year ago

Hello :wave:

In my case, this commit https://github.com/vukoye/xmpp_dart/commit/07d6f54891c0bb55886a3f2182aec4f8039971d2 (@TatankaConCube) introduced critical errors. I am using Flutter 3.7.0 and Fluux.io.

XmlNode.descendants has been changed to XmlNode.children but those two have a different behavior.

/// Return a lazy [Iterable] of the descendants of this node (attributes,
/// children, grandchildren, ...) in document order.
Iterable<XmlNode> get descendants => XmlDescendantsIterable(this);
/// Return the direct children of this node in document order.
List<XmlNode> get children => const [];

From the log i can see the following stanza sent by the server:

<?xml version='1.0'?>
<stream:stream id='1841889393303772883' version='1.0' xml:lang='en'
    xmlns:stream='http://etherx.jabber.org/streams' from='xxx-test.m.in-app.io'
    xmlns='jabber:client'>
<stream:features>
    <mechanisms
        xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
        <mechanism>PLAIN</mechanism>
        <mechanism>X-OAUTH2</mechanism>
    </mechanisms>
    <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
    <push xmlns='p1:push'/>
    <rebind xmlns='p1:rebind'/>
</stream:features>

For me it seem a bit weird that Fluux doesn't close the stream:stream tag but following the RFC6120, the tag seem to be unclosed too. From the debugger i can see that stream:stream wrap stream:features, making it a child.

image

The actual tree looks like steam:stream -> stream:features. With XmlNode.children, we're not able to retrieve the stream:features node since XmlNode.children only return direct children wheres XmlNode.descendants previously return children, grandchildren, ….

I solved the problem by going back to xmpp_stone: 0.4.3-dev.1 and i'll make a fork/pr to have it working in the latest version.

TatankaConCube commented 1 year ago

ok, please make the pull request with your fixes I will check it on my side and publish it with the new dev version

tanukijs commented 1 year ago

Thanks for your fast replying, i'll do that soon!

TatankaConCube commented 1 year ago

@tanukijs the descendants processing was reverted in version 0.4.4-dev.3, please try it. please close this ticket if the issue was resolved

tanukijs commented 1 year ago

Hello @TatankaConCube sorry for the time i took but it seem that the bug is resolved. Thank u.