~singpolyma/network-protocol-xmpp

f1822c3864bbaf20a6d599824b3c7089e89e0192 — Stephen Paul Weber 4 years ago a878a43
Workaround for stream-xmlns issue

From my notes:

I discovered that it expects "{jabber:component:accept}jid" instead of
"{jabber:component:accept}id" for the stream id, which is against the spec.
Additionally, if the server sets the default xmlns to jabber:component:accept
it seems that the id attribute is parsed as having no xmlns and so does not
get found.
1 files changed, 6 insertions(+), 3 deletions(-)

M lib/Network/Protocol/XMPP/Component.hs
M lib/Network/Protocol/XMPP/Component.hs => lib/Network/Protocol/XMPP/Component.hs +6 -3
@@ 20,6 20,7 @@ module Network.Protocol.XMPP.Component
	( runComponent
	) where

import           Control.Applicative ((<|>))
import           Control.Monad (when)
import           Control.Monad.Error (throwError)
import           Data.Bits (shiftR, (.&.))


@@ 62,9 63,11 @@ beginStream jid = do
		Just x -> return x

parseStreamID :: X.Event -> Maybe Text
parseStreamID (X.EventBeginElement name attrs) = X.attributeText
	"{jabber:component:accept}jid"
	(X.Element name attrs [])
parseStreamID (X.EventBeginElement name attrs) = withNS <|> withoutNS
	where
	-- Hack to allow for global namespace without implementing full handling
	withoutNS = X.attributeText "id" (X.Element name attrs [])
	withNS = X.attributeText "{jabber:component:accept}id" (X.Element name attrs [])
parseStreamID _ = Nothing

authenticate :: Text -> Text -> M.XMPP ()