42wim / matterbridge

bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API (mattermost not required!)
Apache License 2.0
6.66k stars 618 forks source link

XMPP New Line EOF #2107

Open stophman1 opened 11 months ago

stophman1 commented 11 months ago

Describe the bug Sending a message with a new line fails to send to XMPP, but is sent to other chats.

To Reproduce Send a message with a new line from a different chat connected to XMPP via the bridge. I tried on both Nextcloud and Discord. For example:

Line1 Line2

Expected behavior The message is sent to XMPP.

Screenshots/debug logs

[0084] DEBUG nctalk:       [handleSendingMessage:bridge/nctalk/nctalk.go:240] <= Message is config.Message{Text:"Line1\nLine2", Channel:"******", Username:"******", UserID:"******", Avatar:"", Account:"nctalk.cloud", Event:"", Protocol:"", Gateway:"", ParentID:"", Timestamp:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), ID:"448", Extra:map[string][]interface {}(nil)}
[0084] DEBUG gateway:      [SendMessage:gateway/gateway.go:499] => Sending config.Message{Text:"Line1\nLine2", Channel:"******", Username:"******", UserID:"******", Avatar:"", Account:"nctalk.cloud", Event:"", Protocol:"nctalk", Gateway:"My Gateway", ParentID:"", Timestamp:time.Date(2023, time.December, 5, 12, 43, 39, 64706900, time.Local), ID:"448", Extra:map[string][]interface {}(nil)} from nctalk.cloud (******) to xmpp.myxmpp (xmppchannel)
[0084] DEBUG xmpp:         [Send:bridge/xmpp/xmpp.go:80] => Receiving config.Message{Text:"Line1\nLine2", Channel:"xmppchannel", Username:"[nctalk] <******> ", UserID:"******", Avatar:"", Account:"nctalk.cloud", Event:"", Protocol:"nctalk", Gateway:"My Gateway", ParentID:"", Timestamp:time.Date(2023, time.December, 5, 12, 43, 39, 64706900, time.Local), ID:"", Extra:map[string][]interface {}(nil)}
[0084] DEBUG xmpp:         [Send:bridge/xmpp/xmpp.go:133] => Sending message config.Message{Text:"Line1\nLine2", Channel:"xmppchannel", Username:"[nctalk] <******> ", UserID:"******", Avatar:"", Account:"nctalk.cloud", Event:"", Protocol:"nctalk", Gateway:"My Gateway", ParentID:"", Timestamp:time.Date(2023, time.December, 5, 12, 43, 39, 64706900, time.Local), ID:"", Extra:map[string][]interface {}(nil)}
[0084] DEBUG gateway:      [SendMessage:gateway/gateway.go:518] mID xmpp.myxmpp: xmppmid
[0084] DEBUG gateway:      [func1:gateway/gateway.go:508] => Send from nctalk.cloud (******) to xmpp.myxmpp (xmppchannel) took 546.6µs
[0084] DEBUG gateway:      [SendMessage:gateway/gateway.go:499] => Sending config.Message{Text:"Line1\nLine2", Channel:"******", Username:"******", UserID:"******", Avatar:"", Account:"nctalk.cloud", Event:"", Protocol:"nctalk", Gateway:"My Gateway", ParentID:"", Timestamp:time.Date(2023, time.December, 5, 12, 43, 39, 64706900, time.Local), ID:"448", Extra:map[string][]interface {}(nil)} from nctalk.cloud (******) to discord.mydiscord (ID:DiscordID)
[0084] DEBUG discord:      [Send:bridge/discord/discord.go:252] => Receiving config.Message{Text:"Line1\nLine2", Channel:"ID:DiscordID", Username:"******", UserID:"******", Avatar:"", Account:"nctalk.cloud", Event:"", Protocol:"nctalk", Gateway:"My Gateway", ParentID:"", Timestamp:time.Date(2023, time.December, 5, 12, 43, 39, 64706900, time.Local), ID:"", Extra:map[string][]interface {}(nil)}
[0084] DEBUG discord:      [handleEventWebhook:bridge/discord/webhook.go:137] Processing webhook sending for message &config.Message{Text:"Line1\nLine2", Channel:"ID:DiscordID", Username:"******", UserID:"******", Avatar:"", Account:"nctalk.cloud", Event:"", Protocol:"nctalk", Gateway:"My Gateway", ParentID:"", Timestamp:time.Date(2023, time.December, 5, 12, 43, 39, 64706900, time.Local), ID:"", Extra:map[string][]interface {}(nil)}
[0084] ERROR xmpp:         [manageConnection:bridge/xmpp/xmpp.go:235] Disconnected. error=XML syntax error on line 53: unexpected EOF
[0084]  INFO xmpp:         [manageConnection:bridge/xmpp/xmpp.go:243] Reconnecting in 1s.
[0085] DEBUG gateway:      [SendMessage:gateway/gateway.go:518] mID discord.mydiscord: discordmid
[0085] DEBUG gateway:      [func1:gateway/gateway.go:508] => Send from nctalk.cloud (******) to discord.mydiscord (ID:DiscordID) took 234.5791ms
[0085] DEBUG gateway:      [SendMessage:gateway/gateway.go:499] => Sending config.Message{Text:"Line1\nLine2", Channel:"******", Username:"******", UserID:"******", Avatar:"", Account:"nctalk.cloud", Event:"", Protocol:"nctalk", Gateway:"My Gateway", ParentID:"", Timestamp:time.Date(2023, time.December, 5, 12, 43, 39, 64706900, time.Local), ID:"448", Extra:map[string][]interface {}(nil)} from nctalk.cloud (******) to mumble.mymumble (7)
[0085] DEBUG mumble:       [Send:bridge/mumble/mumble.go:95] => Received local message config.Message{Text:"Line1\nLine2", Channel:"7", Username:"", UserID:"******", Avatar:"", Account:"nctalk.cloud", Event:"", Protocol:"nctalk", Gateway:"My Gateway", ParentID:"", Timestamp:time.Date(2023, time.December, 5, 12, 43, 39, 64706900, time.Local), ID:"", Extra:map[string][]interface {}(nil)}
[0085] DEBUG gateway:      [func1:gateway/gateway.go:508] => Send from nctalk.cloud (******) to mumble.mymumble (7) took 0s
[0085] DEBUG mumble:       [processMessage:bridge/mumble/mumble.go:222] Processing message Line1
Line2
[0085]  INFO xmpp:         [manageConnection:bridge/xmpp/xmpp.go:246] Reconnecting now.
[0086]  INFO xmpp:         [joinChannels:bridge/bridge.go:77] xmpp.myxmpp: joining xmppchannel (ID: xmppchannelxmpp.myxmpp)
[0086] DEBUG gateway:      [handleMessage:gateway/handlers.go:213] empty channel
[0086] DEBUG gateway:      [handleMessage:gateway/handlers.go:213] empty channel
[0086] DEBUG gateway:      [handleMessage:gateway/handlers.go:213] empty channel
[0086] DEBUG gateway:      [handleMessage:gateway/handlers.go:213] empty channel
[0086] DEBUG xmpp:         [handleXMPP:bridge/xmpp/xmpp.go:298] == Receiving xmpp.Chat{Remote:"xmppchannel@example.com/******", Type:"groupchat", Text:"", Subject:"My subject here", Thread:"", Ooburl:"", Oobdesc:"", ID:"", ReplaceID:"", Roster:xmpp.Roster(nil), Other:[]string{}, OtherElem:[]xmpp.XMLElement(nil), Stamp:time.Date(2023, time.July, 24, 3, 14, 13, 0, time.UTC)}

Environment (please complete the following information):

I also tried:

Additional context The XMPP server is Tigase.

[xmpp.myxmpp]
Server="*****:5222"
Jid="*****@*****"
Password="******"
Muc="*****.******"
Nick="*******"
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "

[[gateway]]
name="My Gateway"
enable=true

[[gateway.inout]]
account="xmpp.myxmpp"
channel="******"