summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-12-08 20:06:11 +0100
committermathieui <mathieui@mathieui.net>2014-12-08 20:07:31 +0100
commitad20d6dbc207ef09eec8b757314a4f084ae04ce9 (patch)
tree84956567cb813dc8b06e1723b33c87a77e84e7ce
parentb852f7279b0abb940f6c404834bca8558e58122e (diff)
downloadpoezio-ad20d6dbc207ef09eec8b757314a4f084ae04ce9.tar.gz
poezio-ad20d6dbc207ef09eec8b757314a4f084ae04ce9.tar.bz2
poezio-ad20d6dbc207ef09eec8b757314a4f084ae04ce9.tar.xz
poezio-ad20d6dbc207ef09eec8b757314a4f084ae04ce9.zip
Add a decode_entities option to the OTR plugin
-rw-r--r--plugins/otr.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/plugins/otr.py b/plugins/otr.py
index 4d5e8828..a632a165 100644
--- a/plugins/otr.py
+++ b/plugins/otr.py
@@ -128,6 +128,13 @@ Configuration
Decode embedded XHTML.
+ decode_entities
+ **Default:** ``false``
+
+ Decode XML and HTML entities (like ``&amp;``) even when the
+ document isn't valid (if it is valid, it will be decoded even
+ without this option).
+
keys_dir
**Default:** ``$XDG_DATA_HOME/poezio/otr``
@@ -155,7 +162,7 @@ Configuration
Log conversations (OTR start/end marker, and messages).
-The :term:`allow_v1`, :term:`allow_v2`, :term:`decode_xhtml`
+The :term:`allow_v1`, :term:`allow_v2`, :term:`decode_xhtml`, :term:`decode_entities`
and :term:`log` configuration parameters are tab-specific.
Important details
@@ -177,6 +184,7 @@ import logging
log = logging.getLogger(__name__)
import os
+import html
import curses
from potr.context import NotEncryptedError, UnencryptedMessage, ErrorReceived, NotOTRMessage,\
@@ -544,11 +552,17 @@ class Plugin(BasePlugin):
nick_color = get_theme().COLOR_REMOTE_USER
body = txt.decode()
+ decode_entities = self.config.get_by_tabname('decode_entities',
+ msg['from'].bare,
+ default=False)
if self.config.get_by_tabname('decode_xhtml', msg['from'].bare, default=True):
try:
body = xhtml.xhtml_to_poezio_colors(body, force=True)
except:
- pass
+ if decode_entities:
+ body = html.unescape(body)
+ elif decode_entities:
+ body = html.unescape(body)
tab.add_message(body, nickname=tab.nick, jid=msg['from'],
forced_user=user, typ=ctx.log,
nick_color=nick_color)