gotr: fix license headers, fix html processing
This commit is contained in:
@@ -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 ' \
|
inactive_tip = 'Communication to this contact is currently ' \
|
||||||
'<i>unencrypted</i>'
|
'<i>unencrypted</i>'
|
||||||
|
|
||||||
import cgi
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
@@ -70,13 +69,13 @@ from message_control import TYPE_CHAT, MessageControl
|
|||||||
from plugins.helpers import log_calls, log
|
from plugins.helpers import log_calls, log
|
||||||
from plugins.plugin import GajimPluginException
|
from plugins.plugin import GajimPluginException
|
||||||
|
|
||||||
from HTMLParser import HTMLParser
|
|
||||||
from htmlentitydefs import name2codepoint
|
|
||||||
|
|
||||||
import ui
|
import ui
|
||||||
|
|
||||||
sys.path.insert(0, os.path.dirname(ui.__file__))
|
sys.path.insert(0, os.path.dirname(ui.__file__))
|
||||||
|
|
||||||
|
from HTMLParser import HTMLParser
|
||||||
|
from htmlentitydefs import name2codepoint
|
||||||
|
|
||||||
HAS_CRYPTO = True
|
HAS_CRYPTO = True
|
||||||
try:
|
try:
|
||||||
import Crypto
|
import Crypto
|
||||||
@@ -597,7 +596,7 @@ class OtrPlugin(GajimPlugin):
|
|||||||
if event.resource:
|
if event.resource:
|
||||||
fjid += '/' + event.resource
|
fjid += '/' + event.resource
|
||||||
|
|
||||||
message = event.xhtml or cgi.escape(event.message)
|
message = event.xhtml or escape(event.message)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
newmsg = self.us[event.account].getContext(fjid).sendMessage(
|
newmsg = self.us[event.account].getContext(fjid).sendMessage(
|
||||||
@@ -642,5 +641,14 @@ class HTMLStripper(HTMLParser):
|
|||||||
if data.startswith('CDATA['):
|
if data.startswith('CDATA['):
|
||||||
self.data += data[6:]
|
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:
|
## TODO:
|
||||||
## - disconnect ctxs on disconnect
|
## - disconnect ctxs on disconnect
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
# python-potr is free software; you can redistribute it and/or modify
|
# python-potr is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Lesser General Public License as published by
|
# it under the terms of the GNU Lesser General Public License as published by
|
||||||
# the Free Software Foundation; either version 3 of the License, or
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# python-potr is distributed in the hope that it will be useful,
|
# python-potr is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
# python-potr is free software; you can redistribute it and/or modify
|
# python-potr is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Lesser General Public License as published by
|
# it under the terms of the GNU Lesser General Public License as published by
|
||||||
# the Free Software Foundation; either version 3 of the License, or
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# python-potr is distributed in the hope that it will be useful,
|
# python-potr is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
@@ -18,7 +18,4 @@
|
|||||||
|
|
||||||
from potr.compatcrypto.common import *
|
from potr.compatcrypto.common import *
|
||||||
|
|
||||||
try:
|
from potr.compatcrypto.pycrypto import *
|
||||||
from potr.compatcrypto.pycrypto import *
|
|
||||||
except ImportError:
|
|
||||||
from potr.compatcrypto.pure import *
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
# python-potr is free software; you can redistribute it and/or modify
|
# python-potr is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Lesser General Public License as published by
|
# it under the terms of the GNU Lesser General Public License as published by
|
||||||
# the Free Software Foundation; either version 3 of the License, or
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# python-potr is distributed in the hope that it will be useful,
|
# python-potr is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
# python-potr is free software; you can redistribute it and/or modify
|
# python-potr is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Lesser General Public License as published by
|
# it under the terms of the GNU Lesser General Public License as published by
|
||||||
# the Free Software Foundation; either version 3 of the License, or
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# python-potr is distributed in the hope that it will be useful,
|
# python-potr is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
# python-potr is free software; you can redistribute it and/or modify
|
# python-potr is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Lesser General Public License as published by
|
# it under the terms of the GNU Lesser General Public License as published by
|
||||||
# the Free Software Foundation; either version 3 of the License, or
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# python-potr is distributed in the hope that it will be useful,
|
# python-potr is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
@@ -167,7 +167,7 @@ class Context(object):
|
|||||||
IGN = None, []
|
IGN = None, []
|
||||||
|
|
||||||
if not self.policyOtrEnabled():
|
if not self.policyOtrEnabled():
|
||||||
return (messageData, [])
|
raise NotOTRMessage(messageData)
|
||||||
|
|
||||||
message = self.parse(messageData)
|
message = self.parse(messageData)
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ class Context(object):
|
|||||||
# but we don't want plaintexts
|
# but we don't want plaintexts
|
||||||
raise UnencryptedMessage(message.msg)
|
raise UnencryptedMessage(message.msg)
|
||||||
|
|
||||||
return (message.msg, [])
|
raise NotOTRMessage(message.msg)
|
||||||
|
|
||||||
return IGN
|
return IGN
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ class Context(object):
|
|||||||
if isinstance(message, proto.Error):
|
if isinstance(message, proto.Error):
|
||||||
raise ErrorReceived(message)
|
raise ErrorReceived(message)
|
||||||
|
|
||||||
raise NotOTRMessage(message)
|
raise NotOTRMessage(messageData)
|
||||||
|
|
||||||
def sendInternal(self, msg, tlvs=[], appdata=None):
|
def sendInternal(self, msg, tlvs=[], appdata=None):
|
||||||
self.sendMessage(FRAGMENT_SEND_ALL, msg, tlvs=tlvs, appdata=appdata,
|
self.sendMessage(FRAGMENT_SEND_ALL, msg, tlvs=tlvs, appdata=appdata,
|
||||||
@@ -302,7 +302,7 @@ class Context(object):
|
|||||||
self.setState(STATE_ENCRYPTED)
|
self.setState(STATE_ENCRYPTED)
|
||||||
|
|
||||||
def sendFragmented(self, msg, policy=FRAGMENT_SEND_ALL, appdata=None):
|
def sendFragmented(self, msg, policy=FRAGMENT_SEND_ALL, appdata=None):
|
||||||
mms = self.user.maxMessageSize
|
mms = self.maxMessageSize(appdata)
|
||||||
msgLen = len(msg)
|
msgLen = len(msg)
|
||||||
if mms != 0 and len(msg) > mms:
|
if mms != 0 and len(msg) > mms:
|
||||||
fms = mms - 19
|
fms = mms - 19
|
||||||
@@ -433,6 +433,10 @@ class Context(object):
|
|||||||
|
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
def maxMessageSize(self, appdata=None):
|
||||||
|
"""Return the max message size for this context."""
|
||||||
|
return self.user.maxMessageSize
|
||||||
|
|
||||||
class Account(object):
|
class Account(object):
|
||||||
contextclass = Context
|
contextclass = Context
|
||||||
def __init__(self, name, protocol, maxMessageSize, privkey=None):
|
def __init__(self, name, protocol, maxMessageSize, privkey=None):
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
# python-potr is free software; you can redistribute it and/or modify
|
# python-potr is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Lesser General Public License as published by
|
# it under the terms of the GNU Lesser General Public License as published by
|
||||||
# the Free Software Foundation; either version 3 of the License, or
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# python-potr is distributed in the hope that it will be useful,
|
# python-potr is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
# python-potr is free software; you can redistribute it and/or modify
|
# python-potr is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Lesser General Public License as published by
|
# it under the terms of the GNU Lesser General Public License as published by
|
||||||
# the Free Software Foundation; either version 3 of the License, or
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# python-potr is distributed in the hope that it will be useful,
|
# python-potr is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
# python-potr is free software; you can redistribute it and/or modify
|
# python-potr is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Lesser General Public License as published by
|
# it under the terms of the GNU Lesser General Public License as published by
|
||||||
# the Free Software Foundation; either version 3 of the License, or
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
# (at your option) any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# python-potr is distributed in the hope that it will be useful,
|
# python-potr is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
|||||||
Reference in New Issue
Block a user