]> git.cworth.org Git - turbot/commitdiff
Drop leading/trailing spaces and empty strings when parsing rounds
authorCarl Worth <cworth@cworth.org>
Sat, 2 Jan 2021 05:31:20 +0000 (21:31 -0800)
committerCarl Worth <cworth@cworth.org>
Sat, 2 Jan 2021 05:31:20 +0000 (21:31 -0800)
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

index d8a252b316d13363d45950adf8b8ad2169f1ba17..e6aadb62269d7b7b8912eeab5d8d8d4bc236a3d3 100644 (file)
@@ -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={