prevent sending invalid XML chars in chat / groupchat and status. Fixes #3296
This commit is contained in:
parent
b3dd46acae
commit
d030cd8b03
|
@ -645,6 +645,11 @@ def ensure_utf8_string(string):
|
||||||
pass
|
pass
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
def remove_invalid_xml_chars(string):
|
||||||
|
if string:
|
||||||
|
string = re.sub(gajim.interface.invalid_XML_chars_re, '', string)
|
||||||
|
return string
|
||||||
|
|
||||||
def get_windows_reg_env(varname, default=''):
|
def get_windows_reg_env(varname, default=''):
|
||||||
'''asks for paths commonly used but not exposed as ENVs
|
'''asks for paths commonly used but not exposed as ENVs
|
||||||
in english Windows 2003 those are:
|
in english Windows 2003 those are:
|
||||||
|
@ -1287,4 +1292,4 @@ def update_optional_features(account = None):
|
||||||
gajim.connections[a].change_status(gajim.SHOW_LIST[connected],
|
gajim.connections[a].change_status(gajim.SHOW_LIST[connected],
|
||||||
gajim.connections[a].status)
|
gajim.connections[a].status)
|
||||||
|
|
||||||
# vim: se ts=3:
|
# vim: se ts=3:
|
||||||
|
|
|
@ -608,6 +608,7 @@ class ChangeStatusMessageDialog:
|
||||||
beg, end = self.message_buffer.get_bounds()
|
beg, end = self.message_buffer.get_bounds()
|
||||||
message = self.message_buffer.get_text(beg, end).decode('utf-8')\
|
message = self.message_buffer.get_text(beg, end).decode('utf-8')\
|
||||||
.strip()
|
.strip()
|
||||||
|
message = helpers.remove_invalid_xml_chars(message)
|
||||||
msg = helpers.to_one_line(message)
|
msg = helpers.to_one_line(message)
|
||||||
if self.show:
|
if self.show:
|
||||||
gajim.config.set('last_status_msg_' + self.show, msg)
|
gajim.config.set('last_status_msg_' + self.show, msg)
|
||||||
|
@ -3847,4 +3848,4 @@ class ESessionInfoWindow:
|
||||||
self.session.verified_identity = True
|
self.session.verified_identity = True
|
||||||
self.update_info()
|
self.update_info()
|
||||||
|
|
||||||
# vim: se ts=3:
|
# vim: se ts=3:
|
||||||
|
|
|
@ -2416,6 +2416,10 @@ class Interface:
|
||||||
# at least one character in 3 parts (before @, after @, after .)
|
# at least one character in 3 parts (before @, after @, after .)
|
||||||
self.sth_at_sth_dot_sth_re = re.compile(r'\S+@\S+\.\S*[^\s)?]')
|
self.sth_at_sth_dot_sth_re = re.compile(r'\S+@\S+\.\S*[^\s)?]')
|
||||||
|
|
||||||
|
# Invalid XML chars
|
||||||
|
invalid_XML_chars = u'[\x00-\x08]|[\x0b-\x0c]|[\x0e-\x19]|[\ud800-\udfff]|[\ufffe-\uffff]'
|
||||||
|
self.invalid_XML_chars_re = re.compile(invalid_XML_chars)
|
||||||
|
|
||||||
re.purge() # clear the regular expression cache
|
re.purge() # clear the regular expression cache
|
||||||
|
|
||||||
def on_emoticon_sort(self, emot1, emot2):
|
def on_emoticon_sort(self, emot1, emot2):
|
||||||
|
@ -3291,4 +3295,4 @@ if __name__ == '__main__':
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print >> sys.stderr, 'KeyboardInterrupt'
|
print >> sys.stderr, 'KeyboardInterrupt'
|
||||||
|
|
||||||
# vim: se ts=3:
|
# vim: se ts=3:
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
import gtkgui_helpers
|
import gtkgui_helpers
|
||||||
|
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
from common import helpers
|
||||||
|
|
||||||
# Derived types MUST register their type IDs here if custom behavor is required
|
# Derived types MUST register their type IDs here if custom behavor is required
|
||||||
TYPE_CHAT = 'chat'
|
TYPE_CHAT = 'chat'
|
||||||
|
@ -154,6 +155,9 @@ class MessageControl:
|
||||||
# Send the given message to the active tab.
|
# Send the given message to the active tab.
|
||||||
# Doesn't return None if error
|
# Doesn't return None if error
|
||||||
jid = self.contact.jid
|
jid = self.contact.jid
|
||||||
|
|
||||||
|
message = helpers.remove_invalid_xml_chars(message)
|
||||||
|
|
||||||
original_message = message
|
original_message = message
|
||||||
conn = gajim.connections[self.account]
|
conn = gajim.connections[self.account]
|
||||||
|
|
||||||
|
@ -176,4 +180,4 @@ class MessageControl:
|
||||||
session = self.session,
|
session = self.session,
|
||||||
original_message = original_message)
|
original_message = original_message)
|
||||||
|
|
||||||
# vim: se ts=3:
|
# vim: se ts=3:
|
||||||
|
|
Loading…
Reference in New Issue