mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 17:24:48 -05:00
LibWeb: Limit HTMLMarqueeElement attributes to allowed values
If `HTMLMarqueeElemnt.scrollAmount` or `HTMLMarqueeElemnt.scrollDelay` is set to a value larger than 2147483647, then it should be set to its default value.
This commit is contained in:
parent
e5c99b475a
commit
a8719a706b
Notes:
github-actions[bot]
2024-11-27 10:03:59 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/a8719a706b0 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2599
3 changed files with 40 additions and 2 deletions
|
@ -67,7 +67,7 @@ WebIDL::UnsignedLong HTMLMarqueeElement::scroll_amount()
|
|||
{
|
||||
// The scrollAmount IDL attribute must reflect the scrollamount content attribute. The default value is 6.
|
||||
if (auto scroll_amount_string = get_attribute(HTML::AttributeNames::scrollamount); scroll_amount_string.has_value()) {
|
||||
if (auto scroll_amount = parse_non_negative_integer(*scroll_amount_string); scroll_amount.has_value())
|
||||
if (auto scroll_amount = parse_non_negative_integer(*scroll_amount_string); scroll_amount.has_value() && *scroll_amount <= 2147483647)
|
||||
return *scroll_amount;
|
||||
}
|
||||
return 6;
|
||||
|
@ -76,6 +76,8 @@ WebIDL::UnsignedLong HTMLMarqueeElement::scroll_amount()
|
|||
// https://html.spec.whatwg.org/multipage/obsolete.html#dom-marquee-scrollamount
|
||||
WebIDL::ExceptionOr<void> HTMLMarqueeElement::set_scroll_amount(WebIDL::UnsignedLong value)
|
||||
{
|
||||
if (value > 2147483647)
|
||||
value = 6;
|
||||
return set_attribute(HTML::AttributeNames::scrollamount, String::number(value));
|
||||
}
|
||||
|
||||
|
@ -84,7 +86,7 @@ WebIDL::UnsignedLong HTMLMarqueeElement::scroll_delay()
|
|||
{
|
||||
// The scrollDelay IDL attribute must reflect the scrolldelay content attribute. The default value is 85.
|
||||
if (auto scroll_delay_string = get_attribute(HTML::AttributeNames::scrolldelay); scroll_delay_string.has_value()) {
|
||||
if (auto scroll_delay = parse_non_negative_integer(*scroll_delay_string); scroll_delay.has_value())
|
||||
if (auto scroll_delay = parse_non_negative_integer(*scroll_delay_string); scroll_delay.has_value() && *scroll_delay <= 2147483647)
|
||||
return *scroll_delay;
|
||||
}
|
||||
return 85;
|
||||
|
@ -93,6 +95,8 @@ WebIDL::UnsignedLong HTMLMarqueeElement::scroll_delay()
|
|||
// https://html.spec.whatwg.org/multipage/obsolete.html#dom-marquee-scrolldelay
|
||||
WebIDL::ExceptionOr<void> HTMLMarqueeElement::set_scroll_delay(WebIDL::UnsignedLong value)
|
||||
{
|
||||
if (value > 2147483647)
|
||||
value = 85;
|
||||
return set_attribute(HTML::AttributeNames::scrolldelay, String::number(value));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,3 +14,35 @@ img.getAttribute("hspace") after img.setAttribute("hspace", "4294967295"): 42949
|
|||
img.hspace after img.setAttribute("hspace", "4294967295"): 0
|
||||
img.getAttribute("hspace") after img.hspace = 4294967295: 0
|
||||
img.hspace after img.hspace = 4294967295: 0
|
||||
marquee.getAttribute("scrollamount") after marquee.setAttribute("scrollAmount", "1"): 1
|
||||
marquee.scrollAmount after marquee.setAttribute("scrollamount", "1"): 1
|
||||
marquee.getAttribute("scrollamount") after marquee.scrollAmount = 1: 1
|
||||
marquee.scrollAmount after marquee.scrollAmount = 1: 1
|
||||
marquee.getAttribute("scrollamount") after marquee.setAttribute("scrollAmount", "2147483647"): 2147483647
|
||||
marquee.scrollAmount after marquee.setAttribute("scrollamount", "2147483647"): 2147483647
|
||||
marquee.getAttribute("scrollamount") after marquee.scrollAmount = 2147483647: 2147483647
|
||||
marquee.scrollAmount after marquee.scrollAmount = 2147483647: 2147483647
|
||||
marquee.getAttribute("scrollamount") after marquee.setAttribute("scrollAmount", "2147483648"): 2147483648
|
||||
marquee.scrollAmount after marquee.setAttribute("scrollamount", "2147483648"): 6
|
||||
marquee.getAttribute("scrollamount") after marquee.scrollAmount = 2147483648: 6
|
||||
marquee.scrollAmount after marquee.scrollAmount = 2147483648: 6
|
||||
marquee.getAttribute("scrollamount") after marquee.setAttribute("scrollAmount", "4294967295"): 4294967295
|
||||
marquee.scrollAmount after marquee.setAttribute("scrollamount", "4294967295"): 6
|
||||
marquee.getAttribute("scrollamount") after marquee.scrollAmount = 4294967295: 6
|
||||
marquee.scrollAmount after marquee.scrollAmount = 4294967295: 6
|
||||
marquee.getAttribute("scrolldelay") after marquee.setAttribute("scrollDelay", "1"): 1
|
||||
marquee.scrollDelay after marquee.setAttribute("scrolldelay", "1"): 1
|
||||
marquee.getAttribute("scrolldelay") after marquee.scrollDelay = 1: 1
|
||||
marquee.scrollDelay after marquee.scrollDelay = 1: 1
|
||||
marquee.getAttribute("scrolldelay") after marquee.setAttribute("scrollDelay", "2147483647"): 2147483647
|
||||
marquee.scrollDelay after marquee.setAttribute("scrolldelay", "2147483647"): 2147483647
|
||||
marquee.getAttribute("scrolldelay") after marquee.scrollDelay = 2147483647: 2147483647
|
||||
marquee.scrollDelay after marquee.scrollDelay = 2147483647: 2147483647
|
||||
marquee.getAttribute("scrolldelay") after marquee.setAttribute("scrollDelay", "2147483648"): 2147483648
|
||||
marquee.scrollDelay after marquee.setAttribute("scrolldelay", "2147483648"): 85
|
||||
marquee.getAttribute("scrolldelay") after marquee.scrollDelay = 2147483648: 85
|
||||
marquee.scrollDelay after marquee.scrollDelay = 2147483648: 85
|
||||
marquee.getAttribute("scrolldelay") after marquee.setAttribute("scrollDelay", "4294967295"): 4294967295
|
||||
marquee.scrollDelay after marquee.setAttribute("scrolldelay", "4294967295"): 85
|
||||
marquee.getAttribute("scrolldelay") after marquee.scrollDelay = 4294967295: 85
|
||||
marquee.scrollDelay after marquee.scrollDelay = 4294967295: 85
|
||||
|
|
|
@ -23,5 +23,7 @@
|
|||
}
|
||||
|
||||
testProperty("img", "hspace", (img) => img.hspace, (img, value) => img.hspace = value);
|
||||
testProperty("marquee", "scrollAmount", (marquee) => marquee.scrollAmount, (marquee, value) => marquee.scrollAmount = value);
|
||||
testProperty("marquee", "scrollDelay", (marquee) => marquee.scrollDelay, (marquee, value) => marquee.scrollDelay = value);
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue