mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibWeb: Fix is_valid_status_text
to handle UTF-8 correctly
This change fixed a WPT subtest which I also imported.
This commit is contained in:
parent
9c76260756
commit
7bb7edd6df
Notes:
github-actions[bot]
2024-12-15 08:34:26 +00:00
Author: https://github.com/F3n67u
Commit: 7bb7edd6df
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2909
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/shannonbooth ✅
4 changed files with 95 additions and 2 deletions
|
@ -85,13 +85,13 @@ GC::Ref<Response> Response::create(JS::Realm& realm, GC::Ref<Infrastructure::Res
|
|||
}
|
||||
|
||||
// https://httpwg.org/specs/rfc9112.html#status.line
|
||||
static bool is_valid_status_text(StringView status_text)
|
||||
static bool is_valid_status_text(String const& status_text)
|
||||
{
|
||||
// A status text is valid if it is either the empty string or matches the reason-phrase token production.
|
||||
// reason-phrase = 1*( HTAB / SP / VCHAR / obs-text )
|
||||
// VCHAR = %x21-7E
|
||||
// obs-text = %x80-FF
|
||||
return all_of(status_text, [](auto c) {
|
||||
return all_of(status_text.code_points(), [](auto c) {
|
||||
return c == '\t' || c == ' ' || (c >= 0x21 && c <= 0x7E) || (c >= 0x80 && c <= 0xFF);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue