dotnet/aspnetcore

Incorrect validation of floating point data

Open

#6326 aperta il 3 gen 2019

Vedi su GitHub
 (4 commenti) (2 reazioni) (0 assegnatari)C# (10.653 fork)batch import
affected-fewarea-mvcbugfeature-mvc-razor-viewshelp wantedseverity-minor

Metriche repository

Star
 (37.933 star)
Metriche merge PR
 (Merge medio 16g 9h) (258 PR mergiate in 30 g)

Descrizione

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

Guida contributor