Open Bug 1945333 Opened 1 month ago Updated 1 day ago

Incorrect Parsing of Floating Point Values in HTML Attributes

Categories

(Core :: DOM: Forms, defect)

Firefox 134
defect

Tracking

()

UNCONFIRMED

People

(Reporter: ibrahim.bendebka, Unassigned, NeedInfo)

References

Details

Attachments

(1 file)

Steps to reproduce:

Write an HTML element that has a floating point attribute:
<input type="number" min="-1." max="10." value="5.">
Include a number with an ending decimal point in the attribute values, as shown above.

Actual results:

The values "-1.", "10.", and "5." are considered valid and are parsed to "-1", "10", and "5" respectively

Expected results:

The values "-1.", "10.", and "5." should be considered invalid according to the specifications.

https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#floating-point-numbers

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Forms' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Forms
Product: Firefox → Core
See Also: → 1945348

Adam worked on similar issues in the past, any idea what's going wrong here? I don't immediately find a wpt for this :-/.

Severity: -- → S3
Flags: needinfo?(avandolder)
See Also: → 1839572

The issue appears to be that we are using our localized decimal parser when value/max/min are set directly as attributes, which does not follow the spec's "valid floating-point number" rules, unlike when they are set as fields - in which case we sanitize the values.

I know Emilio has worked on number sanitization before. I'm not sure if the best solution here would be to sanitize the attributes when they are set, or if instead the parser that is being used can be changed.

Flags: needinfo?(avandolder) → needinfo?(emilio)

(In reply to Adam Vandolder [:avandolder] from comment #3)

The issue appears to be that we are using our localized decimal parser when value/max/min are set directly as attributes, which does not follow the spec's "valid floating-point number" rules, unlike when they are set as fields - in which case we sanitize the values.

Yeah, so much like here, I think we should not allow the localization code to go around for these.

Probably easiest fix would be to add a bool aAllowLocalized or so to ConvertStringToNumber, and bail from NumberInputType::ConvertStringToNumber when false. Adam, do you have cycles to make that change? That way we can also remove the special-case linked there.

Flags: needinfo?(emilio) → needinfo?(avandolder)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: