mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 01:09:25 +00:00
LibURL: Remove unspecified steps in URL file slash parsing state
There were some extra steps in there which produced wrong results for relative file URLs. Fixes 7 test cases in: https://wpt.live/url/url-constructor.any.html We also need to adjust the test results in TestURL. The behaviour tested does not match how URL is specified to work as an absolute relative is given.
This commit is contained in:
committed by
Tim Ledbetter
parent
1d12cb69d4
commit
8723f72f0f
@@ -196,7 +196,9 @@ TEST_CASE(file_url_serialization)
|
||||
TEST_CASE(file_url_relative)
|
||||
{
|
||||
EXPECT_EQ(URL::URL("https://vkoskiv.com/index.html"sv).complete_url("/static/foo.js"sv).serialize(), "https://vkoskiv.com/static/foo.js");
|
||||
EXPECT_EQ(URL::URL("file:///home/vkoskiv/test/index.html"sv).complete_url("/static/foo.js"sv).serialize(), "file:///home/vkoskiv/test/static/foo.js");
|
||||
EXPECT_EQ(URL::URL("file:///home/vkoskiv/test/index.html"sv).complete_url("/static/foo.js"sv).serialize(), "file:///static/foo.js");
|
||||
EXPECT_EQ(URL::URL("https://vkoskiv.com/index.html"sv).complete_url("static/foo.js"sv).serialize(), "https://vkoskiv.com/static/foo.js");
|
||||
EXPECT_EQ(URL::URL("file:///home/vkoskiv/test/index.html"sv).complete_url("static/foo.js"sv).serialize(), "file:///home/vkoskiv/test/static/foo.js");
|
||||
}
|
||||
|
||||
TEST_CASE(about_url)
|
||||
|
||||
@@ -118,6 +118,16 @@ port => ''
|
||||
pathname => '/foo/bar'
|
||||
search => ''
|
||||
hash => ''
|
||||
new URL('/c:/foo/bar', 'file:///c:/baz/qux')
|
||||
protocol => 'file:'
|
||||
username => ''
|
||||
password => ''
|
||||
host => ''
|
||||
hostname => ''
|
||||
port => ''
|
||||
pathname => '/c:/foo/bar'
|
||||
search => ''
|
||||
hash => ''
|
||||
=========================================
|
||||
URL.parse('ftp://serenityos.org:21', undefined)
|
||||
protocol => 'ftp:'
|
||||
@@ -239,3 +249,13 @@ port => ''
|
||||
pathname => '/foo/bar'
|
||||
search => ''
|
||||
hash => ''
|
||||
URL.parse('/c:/foo/bar', 'file:///c:/baz/qux')
|
||||
protocol => 'file:'
|
||||
username => ''
|
||||
password => ''
|
||||
host => ''
|
||||
hostname => ''
|
||||
port => ''
|
||||
pathname => '/c:/foo/bar'
|
||||
search => ''
|
||||
hash => ''
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
{ input: 'http://user%20name:pa%40ss%3Aword@www.ladybird.org' },
|
||||
{ input: 'h\tt\nt\rp://h\to\ns\rt:9\t0\n0\r0/p\ta\nt\rh?q\tu\ne\rry#f\tr\na\rg' },
|
||||
{ input: ' \t', base: 'http://ladybird.org/foo/bar' },
|
||||
{ input: '/c:/foo/bar', base: 'file:///c:/baz/qux' },
|
||||
];
|
||||
|
||||
for (url of urls) {
|
||||
|
||||
@@ -1444,10 +1444,6 @@ URL Parser::basic_parse(StringView raw_input, Optional<URL> const& base_url, Opt
|
||||
// 1. Set url’s host to base’s host.
|
||||
url->m_data->host = base_url->m_data->host;
|
||||
|
||||
// FIXME: The spec does not seem to mention these steps.
|
||||
url->m_data->paths = base_url->m_data->paths;
|
||||
url->m_data->paths.remove(url->m_data->paths.size() - 1);
|
||||
|
||||
// 2. If the code point substring from pointer to the end of input does not start with a Windows drive letter and base’s path[0] is a normalized Windows drive letter, then append base’s path[0] to url’s path.
|
||||
auto substring_from_pointer = input.substring_view(iterator - input.begin()).as_string();
|
||||
if (!starts_with_windows_drive_letter(substring_from_pointer) && is_normalized_windows_drive_letter(base_url->m_data->paths[0]))
|
||||
|
||||
Reference in New Issue
Block a user