mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 07:18:51 +00: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:
parent
ae0c87c747
commit
aafc829e6d
Notes:
github-actions[bot]
2024-11-29 08:50:08 +00:00
Author: https://github.com/tcl3
Commit: aafc829e6d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2619
Reviewed-by: https://github.com/stelar7
4 changed files with 40 additions and 12 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue