From 15cc35cb828b436f9f57a0ab0688b31367050a13 Mon Sep 17 00:00:00 2001 From: Ricky Date: Thu, 15 Mar 2018 23:42:58 +0530 Subject: [PATCH] connectfour/controller: Prevent list access by negative indexing. Currently, if a user does 'move 0', he moves to column 6(last column) in connect_four which is unwanted behaviour and happening due to list getting accessed through negative index (-1). Added a check for that in controller.py file. Fixes #343 --- zulip_bots/zulip_bots/bots/connect_four/connect_four.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zulip_bots/zulip_bots/bots/connect_four/connect_four.py b/zulip_bots/zulip_bots/bots/connect_four/connect_four.py index bbae313..c1b2a0a 100644 --- a/zulip_bots/zulip_bots/bots/connect_four/connect_four.py +++ b/zulip_bots/zulip_bots/bots/connect_four/connect_four.py @@ -47,7 +47,7 @@ class ConnectFourBotHandler(GameAdapter): bot_name = 'connect_four' move_help_message = '* To make your move during a game, type\n' \ '```move ``` or ``````' - move_regex = '(move (\d)$)|((\d)$)' + move_regex = '(move ([1-7])$)|(([1-7])$)' model = ConnectFourModel gameMessageHandler = ConnectFourMessageHandler