mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 11:24:58 +00:00
LibWeb: Implement input email type sanitation algorithm
This commit is contained in:
parent
6fa34a4ee3
commit
dfbc5553f2
1 changed files with 12 additions and 0 deletions
|
@ -506,6 +506,18 @@ DeprecatedString HTMLInputElement::value_sanitization_algorithm(DeprecatedString
|
|||
}
|
||||
return builder.string_view().trim(Infra::ASCII_WHITESPACE);
|
||||
}
|
||||
} else if (type_state() == HTMLInputElement::TypeAttributeState::Email) {
|
||||
// https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email):value-sanitization-algorithm
|
||||
// FIXME: handle the `multiple` attribute
|
||||
// Strip newlines from the value, then strip leading and trailing ASCII whitespace from the value.
|
||||
if (value.contains('\r') || value.contains('\n')) {
|
||||
StringBuilder builder;
|
||||
for (auto c : value) {
|
||||
if (!(c == '\r' || c == '\n'))
|
||||
builder.append(c);
|
||||
}
|
||||
return builder.string_view().trim(Infra::ASCII_WHITESPACE);
|
||||
}
|
||||
} else if (type_state() == HTMLInputElement::TypeAttributeState::Number) {
|
||||
// If the value of the element is not a valid floating-point number, then set it to the empty string instead.
|
||||
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-floating-point-number-values
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue