summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-04-30 01:55:23 +0200
committermathieui <mathieui@mathieui.net>2014-04-30 01:55:23 +0200
commit4e4ab569cf07fabf76339eeace1f6694f3414eff (patch)
treea74007d58875c36aa2bb965bb63c155e7588ea88 /plugins
parentc3dd20fc745b0f4c8fa402052182b5383afbb7f8 (diff)
downloadpoezio-4e4ab569cf07fabf76339eeace1f6694f3414eff.tar.gz
poezio-4e4ab569cf07fabf76339eeace1f6694f3414eff.tar.bz2
poezio-4e4ab569cf07fabf76339eeace1f6694f3414eff.tar.xz
poezio-4e4ab569cf07fabf76339eeace1f6694f3414eff.zip
Fix #2447 (OTR & HTML) -- partial WONTFIX
- Guess-parse the OTR messages in search for xhtml upon arrival - add a configurable option to decode it or not - We have XHTML-IM for a reason, and therefore we will *not* implement a full html parser for clients that dump whatever formatting inside the OTR payload (looking at you, pidgin)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/otr.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/plugins/otr.py b/plugins/otr.py
index 3f22687f..96792a4d 100644
--- a/plugins/otr.py
+++ b/plugins/otr.py
@@ -121,6 +121,11 @@ Configuration
.. glossary::
:sorted:
+ decode_xhtml
+ **Default:** ``true``
+
+ Decode embedded XHTML.
+
keys_dir
**Default:** ``$XDG_DATA_HOME/poezio/otr``
@@ -141,8 +146,8 @@ Configuration
Log conversations (OTR start/end marker, and messages).
-The :term:`allow_v1`, :term:`allow_v2` and :term:`log` configuration
-parameters are tab-specific.
+The :term:`allow_v1`, :term:`allow_v2`, :term:`decode_html`
+and :term:`log` configuration parameters are tab-specific.
Important details
-----------------
@@ -166,6 +171,7 @@ import curses
from potr.context import NotEncryptedError, UnencryptedMessage, ErrorReceived, NotOTRMessage,\
STATE_ENCRYPTED, STATE_PLAINTEXT, STATE_FINISHED, Context, Account, crypt
+import xhtml
from plugin import BasePlugin
from tabs import ConversationTab, DynamicConversationTab, PrivateTab
from common import safeJID
@@ -463,8 +469,14 @@ class Plugin(BasePlugin):
user = None
body = txt.decode()
+ if self.config.get_by_tabname('decode_xhtml', True, msg['from'].bare):
+ try:
+ body = xhtml.xhtml_to_poezio_colors(body, force=True)
+ except:
+ pass
tab.add_message(body, nickname=tab.nick, jid=msg['from'],
- forced_user=user, typ=ctx.log, nick_color=theming.get_theme().COLOR_REMOTE_USER)
+ forced_user=user, typ=ctx.log,
+ nick_color=theming.get_theme().COLOR_REMOTE_USER)
hl(tab)
self.core.refresh_window()
del msg['body']