mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-03 21:10:30 +00:00
LibWeb: Implement input email type sanitation algorithm
This commit is contained in:
parent
6fa34a4ee3
commit
dfbc5553f2
Notes:
sideshowbarker
2024-07-17 05:41:34 +09:00
Author: https://github.com/lanmonster Commit: https://github.com/SerenityOS/serenity/commit/dfbc5553f2 Pull-request: https://github.com/SerenityOS/serenity/pull/16320 Reviewed-by: https://github.com/linusg ✅
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…
Reference in a new issue