Open ajparkerbis opened 7 years ago
Confirming this behavior, with SleekXMPP 1.3.3 and Python 2.7.15 (current Debian Testing):
In [109]: c.send_message("foo@bar", "Hello world")
In [110]: c.send_message("foo@bar", "Hello world", mhtml="Hello <strong>world</strong")
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-110-8543c9085cc5> in <module>()
----> 1 c.send_message("foo@bar", "Hello world", mhtml="Hello <strong>world</strong")
~/.local/share/virtualenvs/bot-xPCSx1pa/local/lib/python2.7/site-packages/sleekxmpp/basexmpp.pyc in send_message(self, mto, mbody, msubject, mtype, mhtml, mfrom, mnick)
542 """
543 self.make_message(mto, mbody, msubject, mtype,
--> 544 mhtml, mfrom, mnick).send()
545
546 def send_presence(self, pshow=None, pstatus=None, ppriority=None,
~/.local/share/virtualenvs/bot-xPCSx1pa/local/lib/python2.7/site-packages/sleekxmpp/basexmpp.pyc in make_message(self, mto, mbody, msubject, mtype, mhtml, mfrom, mnick)
497 message['nick'] = mnick
498 if mhtml is not None:
--> 499 message['html']['body'] = mhtml
500 return message
501
TypeError: 'unicode' object does not support item assignment
@ajparkerbis @LuccoJ: Always present for "master"?
Have you a patch? Can you create a PR?
Attached is a minimal example that triggers this issue, based on send_client.py
from the examples directory; it can be run with ./send_client.py -j somebody@example.org -t somebodyelse@example.net -m ''
(the message is ignored and an hardcoded one is used)
I don't have a patch for SleekXMPP, as this is my first time looking at its code (I'm debugging an issue in software written by somebody else that stopped working, probably between debian jessie (python-sleekxmpp 1.0~beta5) and stable/testing (python(3)-sleekxmpp 1.3.3)).
I've checked the documentation at https://sleekxmpp.readthedocs.io/en/latest/api/basexmpp.html#sleekxmpp.basexmpp.BaseXMPP.send_message and it seems that the declared API hasn't changed, so this looks like a regression.
We were moving a script from a server with version 1.3.1 of sleekxmpp to 1.3.3 and messages sent via mhtml with a space and then colon : caused a hang or broken parsing of mhtml.
Here is a code snippet:
sending most text to the fifo worked fine - sending Problem: even worked fine. It was Problem : that then caused a hang and prompted the TypeError
The error we see is: TypeError: 'unicode' object does not support item assignment -
and it references the mhtml line.
(there's an elif for the other match and an else - everything was working properly with 1.3.1 and we resolved the issue by rolling the new server back to sleekxmpp 1.3.1 from 1.3.3)
*On CentOS 7.3.1611 with python 2.7.5 and sleekxmpp 1.3.3