Skip to content

Commit

Permalink
Edge case fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GGP1 committed Feb 3, 2021
1 parent d7a505d commit d78d19b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion password.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (p *Password) generatePool() {

for _, lvl := range p.Levels {
// Ensure that duplicated levels aren't added twice
if _, ok := unique[lvl]; !ok {
if _, ok := unique[lvl]; !ok && len(lvl) > 0 {
unique[lvl] = struct{}{}
b.Grow(len(lvl))
b.WriteString(string(lvl))
Expand Down Expand Up @@ -210,6 +210,10 @@ repeat:
// validateLevels checks if Exclude contains all the characters of a level that is in Format.
func (p *Password) validateLevels() error {
for _, lvl := range p.Levels {
if len(lvl) < 1 {
continue
}

counter := 0
for _, excl := range p.Exclude {
if strings.Contains(string(lvl), string(excl)) {
Expand Down

0 comments on commit d78d19b

Please sign in to comment.