mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-24 16:40:21 +00:00
LibURL: Convert ASCII only URLs to lowercase during parsing
This fixes an issue where entering EXAMPLE.COM into the URL bar in the browser would fail to load as expected.
This commit is contained in:
parent
fd98076aca
commit
1a4b042664
Notes:
sideshowbarker
2024-07-17 06:40:35 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/1a4b042664 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/127
2 changed files with 24 additions and 1 deletions
|
@ -489,3 +489,24 @@ TEST_CASE(username_and_password)
|
|||
EXPECT_EQ(MUST(url.password()), password);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(ascii_only_url)
|
||||
{
|
||||
{
|
||||
constexpr auto upper_case_url = "HTTP://EXAMPLE.COM:80/INDEX.HTML#FRAGMENT"sv;
|
||||
URL::URL url(upper_case_url);
|
||||
EXPECT(url.is_valid());
|
||||
EXPECT_EQ(url.scheme(), "http");
|
||||
EXPECT_EQ(MUST(url.serialized_host()), "example.com"sv);
|
||||
EXPECT_EQ(url.to_byte_string(), "http://example.com/INDEX.HTML#FRAGMENT");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr auto mixed_case_url = "hTtP://eXaMpLe.CoM:80/iNdEx.HtMl#fRaGmEnT"sv;
|
||||
URL::URL url(mixed_case_url);
|
||||
EXPECT(url.is_valid());
|
||||
EXPECT_EQ(url.scheme(), "http");
|
||||
EXPECT_EQ(MUST(url.serialized_host()), "example.com"sv);
|
||||
EXPECT_EQ(url.to_byte_string(), "http://example.com/iNdEx.HtMl#fRaGmEnT");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -586,7 +586,9 @@ static ErrorOr<String> domain_to_ascii(StringView domain, bool be_strict)
|
|||
// 3. If result is the empty string, domain-to-ASCII validation error, return failure.
|
||||
if (domain.is_empty())
|
||||
return Error::from_string_literal("Empty domain");
|
||||
return String::from_utf8_without_validation(domain.bytes());
|
||||
|
||||
auto lowercase_domain = domain.to_lowercase_string();
|
||||
return String::from_utf8_without_validation(lowercase_domain.bytes());
|
||||
}
|
||||
|
||||
Unicode::IDNA::ToAsciiOptions const options {
|
||||
|
|
Loading…
Reference in a new issue