From 9ad85ea5e734110e6788338aa11c2ce28c042fdd Mon Sep 17 00:00:00 2001 From: Niles Rogoff Date: Thu, 24 Nov 2016 19:56:28 -0800 Subject: [PATCH] Made the word choice code a lot safer --- generate.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/generate.py b/generate.py index 7ccc4d0..a980f88 100644 --- a/generate.py +++ b/generate.py @@ -20,8 +20,7 @@ for font in fonts: word = "" while len(word) < 8: wllen = subprocess.check_output(["wc", "-l", wordlist]).decode("utf-8").strip().split()[0] - # Unsafe - newword = subprocess.check_output(["bash", "-c", "head -n " + str(random.randint(0,int(wllen))) + " " + wordlist + "|tail -n 1"]).decode("utf-8").strip() + newword = random.choice(subprocess.check_output(["cat", wordlist]).decode("utf-8").strip().split()) newword = newword[0].upper() + newword[1:] if '\'' in newword: continue