Skip to content

Commit d7f82db

Browse files
author
jessevz
committed
Added the hashlist of found hash in the searchHashes helper endpoint
1 parent 3e2280a commit d7f82db

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/inc/apiv2/helper/searchHashes.routes.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ public static function getResponse(): array {
110110
* @throws HttpError
111111
*/
112112
public function actionPost($data): object|array|null {
113-
$search = base64_decode($data['searchData']);
113+
$search = base64_decode($data['searchData'], true);
114114
$isSalted = $data['isSalted'];
115115
$separator = $data['separator'];
116116

117117
if (strlen($search) == 0) {
118118
throw new HttpError("Search query cannot be empty!");
119119
}
120-
else if ($search === false) {
120+
else if ($search === false || mb_check_encoding($search, "UTF-8") == false) {
121121
throw new HttpError("Search query is not valid base64!");
122122
}
123123
else if ($isSalted && strlen($separator) == 0) {
@@ -181,7 +181,12 @@ public function actionPost($data): object|array|null {
181181
for ($i = 0; $i < sizeof($hashes); $i++) {
182182
/** @var $hash Hash */
183183
$hash = $joined[Factory::getHashFactory()->getModelName()][$i];
184-
$matches[] = self::obj2Resource($hash);;
184+
$hashlist = $joined[Factory::getHashlistFactory()->getModelName()][$i];
185+
$hashResource = self::obj2Resource($hash);
186+
$hashlistResource = self::obj2Resource($hashlist);
187+
$hashResource["attributes"]["hashlist"] = $hashlistResource["attributes"];
188+
189+
$matches[] = $hashResource;
185190
}
186191
$resultEntry["matches"] = $matches;
187192
}

0 commit comments

Comments
 (0)