]> git.cworth.org Git - turbot-web/commitdiff
Replace slashes in puzzle name to create a filename
authorCarl Worth <cworth@cworth.org>
Wed, 12 Jan 2022 08:11:31 +0000 (00:11 -0800)
committerCarl Worth <cworth@cworth.org>
Wed, 12 Jan 2022 08:11:31 +0000 (00:11 -0800)
Otherwise, the open will fail with a "directory does not exist" error message.

Thanks to MH 2021 for including a puzzle with a '/' in its name to
exercise this bug.

html_generator.py

index de1265c147863589494b39148bdb929ad454d49d..3ee751c989348e6c5004ec399fa6dc403f4972be 100644 (file)
@@ -16,6 +16,7 @@ Requires sorttable.js, which should be included
 """
 import boto3
 from boto3.dynamodb.conditions import Key
+import re
 
 website = "https://halibut.cworth.org/"
 #change this if we're using AWS or some other subdomain instead
@@ -326,7 +327,8 @@ def puzzle_overview(puzzle):
      '\n',
      '</body>\n',
      '</html>\n']
-    underscored = "_".join(name.split())
+    # Replace all spaces and slashes in the name with underscores
+    underscored = re.sub(r'[ /]', '_', name)
     file = "{}.html".format(underscored)
     f = open(file, "w")
     for line in html: