diff options
author | Kjell Braden <afflux.gajim@pentabarf.de> | 2012-10-13 23:22:57 +0400 |
---|---|---|
committer | Kjell Braden <afflux.gajim@pentabarf.de> | 2012-10-13 23:22:57 +0400 |
commit | 54f9be6b79ca87f88b9f41ab43eb2594f017f916 (patch) | |
tree | f66b268c6f531aacfd68a4b6cbe788ac4bb94870 /gotr/otrmodule.py | |
parent | 9e92cbda0b06e56ab060316cdd4505b8c2d20614 (diff) |
gotr: fix license headers, fix html processing
Diffstat (limited to 'gotr/otrmodule.py')
-rw-r--r-- | gotr/otrmodule.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/gotr/otrmodule.py b/gotr/otrmodule.py index 4d6d35a..1199d7f 100644 --- a/gotr/otrmodule.py +++ b/gotr/otrmodule.py @@ -54,7 +54,6 @@ ended_tip = 'The private chat session to this contact has <i>ended</i>' inactive_tip = 'Communication to this contact is currently ' \ '<i>unencrypted</i>' -import cgi import logging import os import pickle @@ -70,13 +69,13 @@ from message_control import TYPE_CHAT, MessageControl from plugins.helpers import log_calls, log from plugins.plugin import GajimPluginException -from HTMLParser import HTMLParser -from htmlentitydefs import name2codepoint - import ui sys.path.insert(0, os.path.dirname(ui.__file__)) +from HTMLParser import HTMLParser +from htmlentitydefs import name2codepoint + HAS_CRYPTO = True try: import Crypto @@ -597,7 +596,7 @@ class OtrPlugin(GajimPlugin): if event.resource: fjid += '/' + event.resource - message = event.xhtml or cgi.escape(event.message) + message = event.xhtml or escape(event.message) try: newmsg = self.us[event.account].getContext(fjid).sendMessage( @@ -642,5 +641,14 @@ class HTMLStripper(HTMLParser): if data.startswith('CDATA['): self.data += data[6:] +def escape(s): + '''Replace special characters "&", "<" and ">" to HTML-safe sequences. + If the optional flag quote is true, the quotation mark character (") + is also translated.''' + s = s.replace("&", "&") # Must be done first! + s = s.replace("<", "<") + s = s.replace(">", ">") + return s + ## TODO: ## - disconnect ctxs on disconnect |