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
10 changes: 10 additions & 0 deletions tests/zxcvbn_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,13 @@ def test_empty_password():
zxcvbn(password, user_inputs=[input_])
except IndexError as ie:
assert False, "Empty password raised IndexError"


def test_user_inputs_side_effects():
password = '7r3iz3|)0uz3'
input_ = [password]

guess1 = zxcvbn(password)['guesses_log10']
zxcvbn('somepassword', user_inputs=input_)
guess2 = zxcvbn(password)['guesses_log10']
assert abs(guess1 - guess2) < 1
4 changes: 3 additions & 1 deletion zxcvbn/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from . import adjacency_graphs
import re
import functools
import copy

from zxcvbn.scoring import most_guessable_match_sequence

Expand Down Expand Up @@ -98,7 +99,8 @@ def wrapper(*args, **kwargs):
# omnimatch -- perform all matches
@ensure_ranked_dictionaries
def omnimatch(password, _ranked_dictionaries=None, user_inputs=[]):
if len(user_inputs):
if _ranked_dictionaries is not None and user_inputs:
_ranked_dictionaries = copy.copy(_ranked_dictionaries)
_ranked_dictionaries['user_inputs'] = build_ranked_dict(user_inputs)

matches = []
Expand Down