dotnet/aspnetcore

Incorrect validation of floating point data

Open

#6 326 ouverte le 3 janv. 2019

Voir sur GitHub
 (4 commentaires) (2 réactions) (0 assignés)C# (10 653 forks)batch import
affected-fewarea-mvcbugfeature-mvc-razor-viewshelp wantedseverity-minor

Métriques du dépôt

Stars
 (37 933 stars)
Métriques de merge PR
 (Merge moyen 16j 9h) (258 PRs mergées en 30 j)

Description

Data of floating point types are incorrectly forced to be numbers in general format by client-side validation, without accounting for the possibility of values displayed or inserted in scientific notation. The data-val-number tag is automatically added to, and cannot be trivially removed from the generated HTML. This causes an inconsistency because it suffices to define a default value small or big enough to be displayed in scientific notation (say, 1.0e-5) to receive a validation error at submission even if the entry is perfectly valid.

To Reproduce

Steps to reproduce the behavior:

  1. Create a model with a double data member.
  2. Scaffold a Razor Page with CRUD for the model at point 1.
  3. Try to insert a value in scientific notation in the text box for the variable of double type.
  4. See error

Expected behavior

There are two possibilities: a) values in scientific notation are accepted b) a custom validator should be able to override the data-val-number setting

Guide contributeur