From 74f85925173ab4c26ab04fd5de55a7443af50835 Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Thu, 6 Mar 2014 12:15:10 +0100 Subject: [PATCH] [gen] Automatically generated passwords and captcha challenges do not include numbers and letters that could be misread. --- fields/string.py | 6 +++++- fields/workflow.py | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fields/string.py b/fields/string.py index f866cc8..6234bea 100644 --- a/fields/string.py +++ b/fields/string.py @@ -32,6 +32,10 @@ alpha = re.compile('[a-zA-Z0-9]') letter = re.compile('[a-zA-Z]') digits = '0123456789' letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' +# No "0" or "1" that could be interpreted as letters "O" or "l". +passwordDigits = '23456789' +# No letters i, l, o (nor lowercase nor uppercase) that could be misread. +passwordLetters = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ' emptyTuple = () # ------------------------------------------------------------------------------ @@ -640,7 +644,7 @@ class String(Field): text = '' # The challenge the user needs to type (minus one char) for i in range(length): j = random.randint(0, 1) - chars = (j == 0) and digits or letters + chars = (j == 0) and passwordDigits or passwordLetters # Choose a char text += chars[random.randint(0,len(chars)-1)] res = {'text': text, 'number': number} diff --git a/fields/workflow.py b/fields/workflow.py index 9497ee0..7960000 100644 --- a/fields/workflow.py +++ b/fields/workflow.py @@ -325,8 +325,6 @@ class Permission: (string) permissions, for referring to it you simply use those strings, you do not create instances of ReadPermission or WritePermission.''' - allowedChars = string.digits + string.letters + '_' - def __init__(self, fieldDescriptor): self.fieldDescriptor = fieldDescriptor