From 87a5f4873bdf8cfa661ae126f279da4dd9010ac7 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 1 Jan 2021 21:31:20 -0800 Subject: [PATCH] Drop leading/trailing spaces and empty strings when parsing rounds Since we're dealing with user input here, it's easy for their to be leading and trailing space (which we don't want as part of the round name), or even an accidentally emty round (from two consecutive commas). Drop any of those spaces and ignore any empty round strings. --- turbot/interaction.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/turbot/interaction.py b/turbot/interaction.py index d8a252b..e6aadb6 100644 --- a/turbot/interaction.py +++ b/turbot/interaction.py @@ -466,6 +466,11 @@ def puzzle_submission(turb, payload, metadata): # Add any new rounds to the database if new_rounds: for round in new_rounds.split(','): + # Drop any leading/trailing spaces from the round name + round = round.strip() + # Ignore any empty string + if not len(round): + continue rounds.append(round) turb.table.put_item( Item={ -- 2.43.0