Closed Bug 840720 Opened 11 years ago Closed 11 years ago

Check for the finiteness of the values returned from the ToDouble calls in the nsHTMLInputElement code

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla21

People

(Reporter: jwatt, Assigned: jwatt)

References

(Depends on 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

It seems that nsTString_CharT::ToDouble can return +/-Infinity while returning NS_OK via the out-param. (See bug 836314 comment 15.) We should check the value returned from the ToDouble calls in ConvertStringToNumber and convert them to NaN if they are not finite so that ConvertStringToNumber's callers handle bad user input correctly.
Flags: in-testsuite?
Summary: Check the values returned from the ToDouble calls in ConvertStringToNumber are finite → Check for the finiteness of the values returned from the ToDouble calls in the nsHTMLInputElement code
I guess the best behaviour would be to do something like:
- parse the value to double;
- check if the value is finite;
- if it is not, return false (all callers correctly check that the method return true).
Attached patch patch (obsolete) — Splinter Review
Attachment #713119 - Flags: review?(mounir)
Blocks: 838256
Depends on: 840735
Attachment #713119 - Attachment is obsolete: true
Attachment #713119 - Flags: review?(mounir)
Attachment #713140 - Flags: review?(mounir)
Attachment #713140 - Attachment is patch: true
Comment on attachment 713140 [details] [diff] [review]
patch + comments requested in bug 838256 comment 13

Review of attachment 713140 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/html/content/src/nsHTMLInputElement.h
@@ +674,5 @@
>    /**
>     * Returns the input's "maximum" (as defined by the HTML5 spec) as a double.
>     * Note this takes account of any default maximum that the type may have.
>     * Returns NaN if the max attribute isn't a valid floating point number and
> +   * the input's type does not have a default maximum. Otherwise, guaranteed 

trailing whitespace
Attachment #713140 - Flags: review?(mounir) → review+
https://hg.mozilla.org/mozilla-central/rev/ca6fb08cb6a2
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: