From 11bb4cdb84f5467e8487d73c305efe0d319b1246 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 17 Sep 2018 17:58:45 +0100 Subject: [PATCH] Avoid '$' in random string generation Until the [upstream bug](https://github.com/joke2k/django-environ/issues/60) is fixed in django-environ, this should prevent people using this template from hitting the bug. Fix #454 --- hooks/post_gen_project.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 669edb0e..b43b08a5 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -118,9 +118,11 @@ def generate_random_string( if using_ascii_letters: symbols += string.ascii_letters if using_punctuation: - symbols += string.punctuation.replace('"', "").replace("'", "").replace( - "\\", "" - ) + all_punctuation = set(string.punctuation) + # These symbols can cause issues in environment variables + unsuitable = {"'", '"', "\\", "$"} + suitable = all_punctuation.difference(unsuitable) + symbols += "".join(suitable) return "".join([random.choice(symbols) for _ in range(length)])