diff --git a/tests/zxcvbn_test.py b/tests/zxcvbn_test.py index 6752c1f..a33c8dd 100644 --- a/tests/zxcvbn_test.py +++ b/tests/zxcvbn_test.py @@ -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 diff --git a/zxcvbn/matching.py b/zxcvbn/matching.py index e211ab3..1f43349 100644 --- a/zxcvbn/matching.py +++ b/zxcvbn/matching.py @@ -2,6 +2,7 @@ from . import adjacency_graphs import re import functools +import copy from zxcvbn.scoring import most_guessable_match_sequence @@ -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 = []