Skip to content
Snippets Groups Projects

Issue #3441726 by Grevil: Undefined array key 2 in Drupal\friendlycaptcha\SiteVerify->verify() when using local endpoint

Merged Issue #3441726 by Grevil: Undefined array key 2 in Drupal\friendlycaptcha\SiteVerify->verify() when using local endpoint
All threads resolved!
All threads resolved!
1 file
+ 16
1
Compare changes
  • Side-by-side
  • Inline
+ 16
1
@@ -167,7 +167,12 @@ class SiteVerify {
if (empty($solution)) {
return self::returnErrorEmptySolution();
}
[$signature, $puzzle, $solutions] = explode('.', $solution);
$solutionArray = explode('.', $solution);
if (count($solutionArray) !== 3) {
$this->logger->critical('The solution is malformed. Expected 3 parts, got %count', ['%count' => count($solutionArray)]);
return self::returnMalformedSolution();
}
[$signature, $puzzle, $solutions] = $solutionArray;
$puzzleBin = base64_decode($puzzle);
$puzzleHex = bin2hex($puzzleBin);
if (($calculated = self::signBuffer($puzzleBin, $this->config->get('site_key'))) !== $signature) {
@@ -250,6 +255,16 @@ class SiteVerify {
return self::returnResponse(FALSE, 'solution_missing');
}
/**
* Helper function to return a response array for a malformed solution.
*
* @return array
* The response array for a malformed solution.
*/
private static function returnMalformedSolution(): array {
return self::returnResponse(FALSE, 'solution_malformed');
}
/**
* Helper function to prepare the response array.
*
Loading