aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2017-07-30 00:59:33 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2017-07-30 00:59:33 +0200
commitd2531a9bf46c18fab76d8f9029263b3d3ebbe30b (patch)
tree5bc53726f525ad1707405add36c60383108b72c1 /wee_slack.py
parent1cf43894a55ef7c765a573d393a180120b6efa51 (diff)
downloadwee-slack-d2531a9bf46c18fab76d8f9029263b3d3ebbe30b.tar.gz
Abort modification of message if encountering line without data
Not sure if this can happen. The weechat documentation doesn't state that it can, but since the if condition was there, maybe it can. If it can and does happen, abort the modification, which is better than something unexpected happening.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index ad196e6..dd8a00d 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2733,6 +2733,10 @@ def modify_buffer_line(buffer, new_line, timestamp, time_id):
# since number_of_matching_lines is non-zero, we have
# already reached the message and can stop traversing
break
+ else:
+ dbg(('Encountered line without any data while trying to modify '
+ 'line. This is not handled, so aborting modification.'))
+ return w.WEECHAT_RC_ERROR
# move backwards one line and try again - exit the while if you hit the end
line_pointer = w.hdata_move(struct_hdata_line, line_pointer, -1)
@@ -2772,6 +2776,9 @@ def modify_print_time(buffer, new_id, time):
if data:
prefix = w.hdata_string(struct_hdata_line_data, data, 'prefix')
w.hdata_update(struct_hdata_line_data, data, {"date_printed": new_id})
+ else:
+ dbg('Encountered line without any data while setting message id.')
+ return w.WEECHAT_RC_ERROR
# move backwards one line and repeat, so all the lines of the message are set
# exit when you reach a prefix, which means you have reached the
# first line of the message, or if you hit the end