Skip to content

Commit

Permalink
Fix endless loop whe generating uppercase char w/o ambiguous (#15)
Browse files Browse the repository at this point in the history
fix #13

Also modify testGenerateAmbiguous, ambiguous characters come from the
uppercase set, thus it required to enable $capitalize in order to get
some ambiguous ones.
  • Loading branch information
pips- authored and roderik committed Nov 30, 2017
1 parent 299a78f commit 7ecf653
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/PWGen.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ private function pw_phonemes()
if ($this->pwgen_flags & self::PW_UPPERS) {
if (($first || $flags & self::CONSONANT) &&
(self::my_rand(0, 9) < 2) &&
($this->pwgen_flags & self::PW_AMBIGUOUS) &&
strpos(self::$pw_ambiguous, strtoupper($this->password[$c])) === false) {
(($this->pwgen_flags & self::PW_AMBIGUOUS) ||
strpos(self::$pw_ambiguous, strtoupper($this->password[$c])) === false)) {
$this->password[$c] = strtoupper($this->password[$c]);
$feature_flags &= ~self::PW_UPPERS;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/PWGen/PWGenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testGenerateCapitalize()

public function testGenerateAmbiguous()
{
$pwgen = new PWGen(20, false, false, false, true);
$pwgen = new PWGen(20, false, false, true, true);

$this->assertEquals(20, $pwgen->getLength());
$this->assertTrue($pwgen->hasAmbiguous());
Expand Down

0 comments on commit 7ecf653

Please sign in to comment.