mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 09:39:39 +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:
parent
1d12cb69d4
commit
8723f72f0f
Notes:
github-actions[bot]
2024-08-06 06:59:00 +00:00
Author: https://github.com/shannonbooth
Commit: 8723f72f0f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/985
Reviewed-by: https://github.com/tcl3 ✅
4 changed files with 24 additions and 5 deletions
|
@ -196,7 +196,9 @@ TEST_CASE(file_url_serialization)
|
||||||
TEST_CASE(file_url_relative)
|
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("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)
|
TEST_CASE(about_url)
|
||||||
|
|
|
@ -118,6 +118,16 @@ port => ''
|
||||||
pathname => '/foo/bar'
|
pathname => '/foo/bar'
|
||||||
search => ''
|
search => ''
|
||||||
hash => ''
|
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)
|
URL.parse('ftp://serenityos.org:21', undefined)
|
||||||
protocol => 'ftp:'
|
protocol => 'ftp:'
|
||||||
|
@ -239,3 +249,13 @@ port => ''
|
||||||
pathname => '/foo/bar'
|
pathname => '/foo/bar'
|
||||||
search => ''
|
search => ''
|
||||||
hash => ''
|
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: '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: '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: ' \t', base: 'http://ladybird.org/foo/bar' },
|
||||||
|
{ input: '/c:/foo/bar', base: 'file:///c:/baz/qux' },
|
||||||
];
|
];
|
||||||
|
|
||||||
for (url of urls) {
|
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.
|
// 1. Set url’s host to base’s host.
|
||||||
url->m_data->host = base_url->m_data->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.
|
// 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();
|
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]))
|
if (!starts_with_windows_drive_letter(substring_from_pointer) && is_normalized_windows_drive_letter(base_url->m_data->paths[0]))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue