| Summary: | Enforce HTML range restriction on setting unsigned attribute values | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Ahmad Saleem <ahmad.saleem792> |
| Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED INVALID | ||
| Severity: | Normal | CC: | annevk, rniwa, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari Technology Preview | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
|
Description
Ahmad Saleem
2023-02-10 17:18:24 PST
We are using 'limitToOnlyHTMLNonNegative' to restrict it to restrict it to only positive but do we need upper clamping? @rniwa - appreciate your input? Thanks! (In reply to Ahmad Saleem from comment #2) > We are using 'limitToOnlyHTMLNonNegative' to restrict it to restrict it to > only positive but do we need upper clamping? > > @rniwa - appreciate your input? Thanks! I think search fox link messed up - https://searchfox.org/wubkat/source/Source/WebCore/dom/Element.cpp#4323 We are already doing it:
void Element::setUnsignedIntegralAttribute(const QualifiedName& attributeName, unsigned value)
{
setAttribute(attributeName, AtomString::number(limitToOnlyHTMLNonNegative(value)));
}
From this `limitToOnlyHTMLNonNegative`:
// https://html.spec.whatwg.org/#reflecting-content-attributes-in-idl-attributes:idl-unsigned-long
inline unsigned limitToOnlyHTMLNonNegative(unsigned value, unsigned defaultValue = 0)
{
ASSERT(defaultValue <= maxHTMLNonNegativeInteger);
return value <= maxHTMLNonNegativeInteger ? value : defaultValue;
}
and then `maxHTMLNonNegativeInteger` goes to:
static const unsigned maxHTMLNonNegativeInteger = 2147483647;
Blink proposed - 0x7fffffffu = 2147483647 (in Decimal).
|