[avm] limit the number of emoticons / latex formulas to 100 per message. Fixes #5129
This commit is contained in:
parent
d0da7cb14e
commit
3a09185cb9
1 changed files with 9 additions and 3 deletions
|
@ -953,10 +953,13 @@ class ConversationTextview(gobject.GObject):
|
||||||
|
|
||||||
buffer_ = self.tv.get_buffer()
|
buffer_ = self.tv.get_buffer()
|
||||||
|
|
||||||
start = 0
|
|
||||||
end = 0
|
|
||||||
index = 0
|
index = 0
|
||||||
|
|
||||||
|
# Too many special elements (emoticons, LaTeX formulas, etc)
|
||||||
|
# may cause Gajim to freeze (see #5129).
|
||||||
|
# We impose an arbitrary limit of 100 specials per message.
|
||||||
|
specials_limit = 100
|
||||||
|
|
||||||
# basic: links + mail + formatting is always checked (we like that)
|
# basic: links + mail + formatting is always checked (we like that)
|
||||||
if gajim.config.get('emoticons_theme'): # search for emoticons & urls
|
if gajim.config.get('emoticons_theme'): # search for emoticons & urls
|
||||||
iterator = gajim.interface.emot_and_basic_re.finditer(otext)
|
iterator = gajim.interface.emot_and_basic_re.finditer(otext)
|
||||||
|
@ -965,7 +968,7 @@ class ConversationTextview(gobject.GObject):
|
||||||
for match in iterator:
|
for match in iterator:
|
||||||
start, end = match.span()
|
start, end = match.span()
|
||||||
special_text = otext[start:end]
|
special_text = otext[start:end]
|
||||||
if start != 0:
|
if start > index:
|
||||||
text_before_special_text = otext[index:start]
|
text_before_special_text = otext[index:start]
|
||||||
end_iter = buffer_.get_end_iter()
|
end_iter = buffer_.get_end_iter()
|
||||||
# we insert normal text
|
# we insert normal text
|
||||||
|
@ -975,6 +978,9 @@ class ConversationTextview(gobject.GObject):
|
||||||
|
|
||||||
# now print it
|
# now print it
|
||||||
self.print_special_text(special_text, other_tags)
|
self.print_special_text(special_text, other_tags)
|
||||||
|
specials_limit -= 1
|
||||||
|
if specials_limit <= 0:
|
||||||
|
break
|
||||||
|
|
||||||
return index # the position after *last* special text
|
return index # the position after *last* special text
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue