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

reCAPTCHA Minimum Score validation will fail for the default value of 0.7 when the server is running with a non en-us configuration #706

Open
vbaderks opened this issue Oct 26, 2024 · 0 comments
Labels

Comments

@vbaderks
Copy link
Contributor

Scenario:

I have das-blog-core v8.0.1200 running on my Windows dev machine. My Windows language & region configuration is English (Netherlands) and regional format (Dutch). In this scenario the default value for the reCAPTCHA Minimum Score is initially set to 0,7 instead of 0.7. Which makes sense as the decimal symbol is a comma instead of a dot in the Netherlands. Pressing the save button without changing anything, triggers the validation that the value is incorrect. Changing the value manually to 0.7 works, but triggers a StackOverflowException (see issue #705)

Analysis of the generated HTML shows that the controller generates: <input type="text" value="0,7" ....> for this input field.

A good matching description of this problem is also described in: dotnet/aspnetcore#6566
It was however not easy to see how to apply to "correct" solution from this discussion to the das-blog-core source code.

vbaderks added a commit to vbaderks/dasblog-core that referenced this issue Nov 22, 2024
…string#706

Using type="number" will ensure that the decimal symbol is always a dot, which will prevent that the validation will fail when the server is running on a non en-us configuration.
The HTML input element type="number" also display a spinner, The default step size is 1, changed it to .1 to make the spinner useful.

Remark 1: the input element number also provides min/max settings to limit the user input. A custom HtmlHelperExtensions would be needed however to extract the range values from the model to set these values.
Adding min/max manuallly in the .cshtml file is also possible but would duplicate the configuration SiteViewModel. Client validation will also ensure the range, so no functionality is lost.

Remark 2: an alternative would be change the page to use ASP.NET Tag Helpers (asp-for), which is used in some other pages of DasBlog, but this change would be much larger.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants