Ticket #9687: more_randomness_in_secret_key.patch

File more_randomness_in_secret_key.patch, 851 bytes (added by paulway@…, 7 years ago)

Patch in svn diff format

  • core/management/commands/startproject.py

     
    3232        main_settings_file = os.path.join(directory, project_name, 'settings.py')
    3333        settings_contents = open(main_settings_file, 'r').read()
    3434        fp = open(main_settings_file, 'w')
    35         secret_key = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])
     35        charset = [chr(i) for i in range(32,38) + range(40,127)]
     36        secret_key = ''.join([choice(charset) for i in range(50)])
    3637        settings_contents = re.sub(r"(?<=SECRET_KEY = ')'", secret_key + "'", settings_contents)
    3738        fp.write(settings_contents)
    3839        fp.close()
Back to Top