Correct input[type=number] value sanitization for user-input
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Nov 2012 13:11:46 +0000 (13:11 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Nov 2012 13:11:46 +0000 (13:11 +0000)
commit5175d23d0b66444e2a957ebb2c084a74decc1290
treeaa41ad08dc27c4f6cec09c4ce8f79c8b333defc8
parent0bae71df50a491a2514e28a19d62f5c96a1d81c5
Correct input[type=number] value sanitization for user-input
https://bugs.webkit.org/show_bug.cgi?id=103018

Reviewed by Kentaro Hara.

Source/WebCore:

If a number field has non-number string, HTMLInputElement::value is not
updated and returns the past valid value. It doesn't match to the value
sanitization algorithm defined by the HTML standard [1], and Opera's
behavior. We should sanitize non-number strings to "".

[1] http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#number-state-(type=number)
> The value sanitization algorithm is as follows: If the value of the
> element is not a valid floating-point number, then set it to the empty
> string instead.

No new tests. Update existing tests;
fast/forms/number/number-commit-valid-only.html and
fast/forms/number/number-unacceptable-style.html

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::subtreeHasChanged):
Remove isAcceptableValue check.

* html/HTMLInputElement.h:
(HTMLInputElement): isAcceptableValue is no longer needed.
* html/InputType.cpp: Remove isAcceptableValue.
* html/InputType.h: Ditto.
* html/NumberInputType.cpp: Ditto.
(WebCore::NumberInputType::hasUnacceptableValue):
Fold the isAcceptableValue content into this.
* html/NumberInputType.h:
(NumberInputType): Remove isAcceptableValue.

LayoutTests:

* fast/forms/number/number-commit-valid-only-expected.txt:
* fast/forms/number/number-commit-valid-only.html:
Update the expected HTMLInputElement::value results.
* fast/forms/number/number-unacceptable-style-expected.txt:
* fast/forms/number/number-unacceptable-style.html:
Add some checks for HTMLInputElement::value.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135598 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/number/number-commit-valid-only-expected.txt
LayoutTests/fast/forms/number/number-commit-valid-only.html
LayoutTests/fast/forms/number/number-unacceptable-style-expected.txt
LayoutTests/fast/forms/number/number-unacceptable-style.html
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/InputType.cpp
Source/WebCore/html/InputType.h
Source/WebCore/html/NumberInputType.cpp
Source/WebCore/html/NumberInputType.h