Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ Usages
**is\_safe\_username** takes the following optional arguments:

- ``whitelist``: a list of words that should be considered as always
- ``whitelist``: a case insensitive list of words that should be considered as always
safe. Default: ``[]``
- ``blacklist``: a list of words that should be considered as unsafe. Default: ``[]``
- ``blacklist``: a case insensitive list of words that should be considered as unsafe. Default: ``[]``
- ``max_length``: specify the maximun character a username can have. Default: ``None``
- ``regex``: regular expression string that must pass before the banned
words is checked.
Expand Down
4 changes: 2 additions & 2 deletions usernames/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def is_safe_username(
if not re.match(regex, username):
return False
wordlist = get_reserved_wordlist()
whitelist = set(whitelist)
blacklist = set(blacklist)
whitelist = set([each_whitelisted_name.lower() for each_whitelisted_name in whitelist])
blacklist = set([each_blacklisted_name.lower() for each_blacklisted_name in blacklist])
wordlist = wordlist - whitelist
wordlist = wordlist.union(blacklist)
return False if username.lower() in wordlist else True