File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,3 +46,13 @@ def test_empty_password():
4646 zxcvbn (password , user_inputs = [input_ ])
4747 except IndexError as ie :
4848 assert False , "Empty password raised IndexError"
49+
50+
51+ def test_user_inputs_side_effects ():
52+ password = '7r3iz3|)0uz3'
53+ input_ = [password ]
54+
55+ guess1 = zxcvbn (password )['guesses_log10' ]
56+ zxcvbn ('somepassword' , user_inputs = input_ )
57+ guess2 = zxcvbn (password )['guesses_log10' ]
58+ assert abs (guess1 - guess2 ) < 1
Original file line number Diff line number Diff line change 22from . import adjacency_graphs
33import re
44import functools
5+ import copy
56
67from zxcvbn .scoring import most_guessable_match_sequence
78
@@ -40,6 +41,12 @@ def wrapper(*args, **kwargs):
4041 return wrapper
4142
4243
44+ @ensure_ranked_dictionaries
45+ def add_frequency_lists (frequency_lists_ , * , _ranked_dictionaries ):
46+ for name , lst in frequency_lists_ .items ():
47+ _ranked_dictionaries [name ] = build_ranked_dict (lst )
48+
49+
4350GRAPHS = {
4451 'qwerty' : adjacency_graphs .ADJACENCY_GRAPHS ['qwerty' ],
4552 'dvorak' : adjacency_graphs .ADJACENCY_GRAPHS ['dvorak' ],
@@ -98,7 +105,8 @@ def wrapper(*args, **kwargs):
98105# omnimatch -- perform all matches
99106@ensure_ranked_dictionaries
100107def omnimatch (password , _ranked_dictionaries = None , user_inputs = []):
101- if len (user_inputs ):
108+ if _ranked_dictionaries is not None and user_inputs :
109+ _ranked_dictionaries = copy .copy (_ranked_dictionaries )
102110 _ranked_dictionaries ['user_inputs' ] = build_ranked_dict (user_inputs )
103111
104112 matches = []
You can’t perform that action at this time.
0 commit comments