mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Don't allow HTMLTextAreaElement rows and cols to be set to 0
In this case we should fall back to the default value.
This commit is contained in:
committed by
Andreas Kling
parent
ae0c87c747
commit
aafc829e6d
Notes:
github-actions[bot]
2024-11-29 08:50:08 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/aafc829e6de Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2619 Reviewed-by: https://github.com/stelar7
@@ -299,16 +299,16 @@ unsigned HTMLTextAreaElement::cols() const
|
||||
return 20;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> HTMLTextAreaElement::set_cols(unsigned cols)
|
||||
WebIDL::ExceptionOr<void> HTMLTextAreaElement::set_cols(WebIDL::UnsignedLong cols)
|
||||
{
|
||||
if (cols > 2147483647)
|
||||
if (cols == 0 || cols > 2147483647)
|
||||
cols = 20;
|
||||
|
||||
return set_attribute(HTML::AttributeNames::cols, String::number(cols));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-textarea-rows
|
||||
unsigned HTMLTextAreaElement::rows() const
|
||||
WebIDL::UnsignedLong HTMLTextAreaElement::rows() const
|
||||
{
|
||||
// The cols and rows attributes are limited to only positive numbers with fallback. The rows IDL attribute's default value is 2.
|
||||
if (auto rows_string = get_attribute(HTML::AttributeNames::rows); rows_string.has_value()) {
|
||||
@@ -318,9 +318,9 @@ unsigned HTMLTextAreaElement::rows() const
|
||||
return 2;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> HTMLTextAreaElement::set_rows(unsigned rows)
|
||||
WebIDL::ExceptionOr<void> HTMLTextAreaElement::set_rows(WebIDL::UnsignedLong rows)
|
||||
{
|
||||
if (rows > 2147483647)
|
||||
if (rows == 0 || rows > 2147483647)
|
||||
rows = 2;
|
||||
|
||||
return set_attribute(HTML::AttributeNames::rows, String::number(rows));
|
||||
|
||||
Reference in New Issue
Block a user