LibWeb: Limit progress element attribute values to the correct ranges

The max attribute is now clamped to ensure it is limited to positive
numbers and the value attribute is clamped to ensure it is non-negative.
This commit is contained in:
Tim Ledbetter 2024-03-18 06:13:01 +00:00 committed by Andreas Kling
parent ecbc686bc8
commit 3a7a84f39b
Notes: sideshowbarker 2024-07-16 21:42:29 +09:00
3 changed files with 10 additions and 2 deletions

View file

@ -49,7 +49,7 @@ double HTMLProgressElement::value() const
WebIDL::ExceptionOr<void> HTMLProgressElement::set_value(double value)
{
if (value < 0)
return {};
value = 0;
TRY(set_attribute(HTML::AttributeNames::value, MUST(String::number(value))));
update_progress_value_element();
@ -69,7 +69,7 @@ double HTMLProgressElement::max() const
WebIDL::ExceptionOr<void> HTMLProgressElement::set_max(double value)
{
if (value <= 0)
return {};
value = 1;
TRY(set_attribute(HTML::AttributeNames::max, MUST(String::number(value))));
update_progress_value_element();