LibWeb: Chain all accept attribute checks in parse_accept_attribute()

The wildcard checks for audio/* and video/* are standalone if
statements, while the MIME-type and extension branches are
else-if chained only to the image/* check. When a token like
"audio/*" arrives, it matches the first if (adding
FileType::Audio) and then falls through to the MIME-type
else-if. MimeType::parse() accepts the wildcard because * is a
valid HTTP token code point, so a second MimeType{"audio/*"}
entry is added. FileFilter::add_filter() deduplicates within
variant types but cannot catch this cross-type duplication.

This chains all five conditions into a single if/else-if,
matching the spec's mutually exclusive "one of the following"
wording.
This commit is contained in:
Praise-Garfield 2026-02-13 13:33:17 +00:00 committed by Tim Flynn
parent 56287ca90f
commit 36d8191a3d
Notes: github-actions[bot] 2026-02-13 20:34:07 +00:00

View file

@ -333,12 +333,12 @@ FileFilter HTMLInputElement::parse_accept_attribute() const
// The string "video/*"
// Indicates that video files are accepted.
if (value.equals_ignoring_ascii_case("video/*"sv))
else if (value.equals_ignoring_ascii_case("video/*"sv))
filter.add_filter(FileFilter::FileType::Video);
// The string "image/*"
// Indicates that image files are accepted.
if (value.equals_ignoring_ascii_case("image/*"sv))
else if (value.equals_ignoring_ascii_case("image/*"sv))
filter.add_filter(FileFilter::FileType::Image);
// A valid MIME type string with no parameters