Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit 6739ec2

Browse files
author
the-djmaze
committed
Bugfix haveibeenpwned suffix handling
1 parent c9d3f3d commit 6739ec2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

plugins/haveibeenpwned/index.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public function HibpCheck()
5151
}
5252

5353
$pass = \sha1($oAccount->ImapPass());
54-
$response = $HTTP->doRequest('GET', 'https://api.pwnedpasswords.com/range/' . \substr($pass, 0, 5));
54+
$prefix = \substr($pass, 0, 5);
55+
$suffix = \substr($pass, 5);
56+
$response = $HTTP->doRequest('GET', "https://api.pwnedpasswords.com/range/{$prefix}");
5557
$passwords = [];
5658
foreach (\preg_split('/\\R/', $response->body) as $entry) {
5759
if ($entry) {
@@ -61,8 +63,7 @@ public function HibpCheck()
6163
}
6264

6365
return $this->jsonResponse(__FUNCTION__, array(
64-
'pwned' => isset($passwords[$pass]) ? $passwords[$pass] : 0,
65-
// 'passwords' => $passwords,
66+
'pwned' => isset($passwords[$suffix]) ? $passwords[$suffix] : 0,
6667
'breached' => $breached ? [
6768
'request_uri' => $breached->request_uri,
6869
'final_uri' => $breached->final_uri,

0 commit comments

Comments
 (0)