Skip to content

Commit

Permalink
handle potential parse_str error
Browse files Browse the repository at this point in the history
  • Loading branch information
Tustin committed Oct 23, 2022
1 parent 16032a3 commit 2d8b0ab
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ public function loginWithNpsso(string $npsso)
throw new \Exception('Missing redirect location from oauth/authorize.');
}

parse_str(parse_url($location, PHP_URL_QUERY), $params);
$parsedUrl = parse_url($location, PHP_URL_QUERY);

if ($parsedUrl === null) {
throw new \Exception('Failed parsing location header');
}

parse_str($parsedUrl, $params);

if (!array_key_exists('code', $params)) {
throw new \Exception('Missing code from oauth/authorize.');
Expand Down

0 comments on commit 2d8b0ab

Please sign in to comment.