dotnet/aspnetcore

Incorrect validation of floating point data

Open

#6,326 建立於 2019年1月3日

在 GitHub 查看
 (4 留言) (2 反應) (0 負責人)C# (37,933 star) (10,653 fork)batch import
affected-fewarea-mvcbugfeature-mvc-razor-viewshelp wantedseverity-minor

描述

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

貢獻者指南