Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recapcha: Wrong score conversion #7045

Open
SVillette opened this issue Feb 8, 2024 · 0 comments
Open

Recapcha: Wrong score conversion #7045

SVillette opened this issue Feb 8, 2024 · 0 comments

Comments

@SVillette
Copy link

SVillette commented Feb 8, 2024

Description

Hi guys,
I just installed this package and noticed a strange behaviour when an object of class Google\Cloud\RecaptchaEnterprise\V1\RiskAnalysis is hydrated from the json response when creating an assessment (especially the score property). I discovered this bug when I tested recaptcha behaviour with a score threshold of 0.9 and it failed because the score was 0.8999999761581421.

Environment details

  • OS: MacOS
  • PHP version: 8.2
  • Package name and version: googleapis/google-cloud-php-recaptcha-enterprise v1.8.1

Code example

$var = 0.9;
GPBUtil::checkFloat($var);
var_dump($var);

$var = 0.7;
GPBUtil::checkFloat($var);
var_dump($var);

$var = 0.3;
GPBUtil::checkFloat($var);
var_dump($var);

$var = 0.1;
GPBUtil::checkFloat($var);
var_dump($var);

The output is the following : (from https://3v4l.org/CgGYZ)

8.0 - 8.3
float(0.8999999761581421) 
float(0.699999988079071) 
float(0.30000001192092896) 
float(0.10000000149011612)
5.4 - 8.0
float(0.89999997615814)
float(0.69999998807907)
float(0.30000001192093)
float(0.10000000149012)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant