Sharp.Xmpp icon indicating copy to clipboard operation
Sharp.Xmpp copied to clipboard

Sending text that includes HTML tags.

Open trenki2 opened this issue 8 years ago • 4 comments

When i try to send a message with the content <&> nothing is sent. Similarly when I try to send content that includes HTML tags bold the content is not sent verbatim.

When I manually escape the text before calling SendMessage() using HttpUtility.HtmlEncode(xml) it works as expected. I guess the message text would have to be escaped inside the library?

trenki2 avatar Mar 02 '16 12:03 trenki2

Sorry I can't create a PR for this just yet, but we have a fix for this at https://github.com/REPLDigital/Sharp.Xmpp/commit/4159c0908e096e88132827a4a3394db2b587b7ab which should be quite painless to make

Cakez0r avatar Mar 02 '16 15:03 Cakez0r

Yes, text has to escaped manually before using the library. However, @Cakez0r is elegant, thus with his permission I will include it in the library. Please note that this applies only for XMPP messages and not to any custom iq stanzas.

pgstath avatar Mar 02 '16 18:03 pgstath

@pgstath Fine with me

Although I just noticed there should be null checks here too.

Cakez0r avatar Mar 02 '16 19:03 Cakez0r

With that patch when I create a message with the body "body" and afterwards access the Body property I get returned the now modified body. This is unexpected, I think in that case I should get the body that I supplied. I would have to either unescape the body in the xmlelement or keep a separate variable with the original.

And when setting the Body property one would have to escape the text too. So i think the logic has to go into the property setter and getter.

trenki2 avatar Mar 02 '16 19:03 trenki2