mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 04:17:34 +00:00
AK: Don't store parts of URLs percent decoded
As noted in serval comments doing this goes against the WC3 spec, and breaks parsing then re-serializing URLs that contain percent encoded data, that was not encoded using the same character set as the serializer. For example, previously if you had a URL like: https:://foo.com/what%2F%2F (the path is what + '//' percent encoded) Creating URL("https:://foo.com/what%2F%2F").serialize() would return: https://foo.com/what// Which is incorrect and not the same as the URL we passed. This is because the re-serializing uses the PercentEncodeSet::Path which does not include '/'. Only doing the percent encoding in the setters fixes this, which is required to navigate to Google Street View (which includes a percent encoded URL in its URL). Seems to fix #13477 too
This commit is contained in:
parent
d2fc8efd9e
commit
8283e8b88c
5 changed files with 85 additions and 51 deletions
|
@ -151,7 +151,7 @@ TEST_CASE(file_url_with_encoded_characters)
|
|||
URL url("file:///my/file/test%23file.txt"sv);
|
||||
EXPECT(url.is_valid());
|
||||
EXPECT_EQ(url.scheme(), "file");
|
||||
EXPECT_EQ(url.path(), "/my/file/test#file.txt");
|
||||
EXPECT_EQ(url.path(), "/my/file/test%23file.txt");
|
||||
EXPECT(url.query().is_null());
|
||||
EXPECT(url.fragment().is_null());
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ TEST_CASE(unicode)
|
|||
{
|
||||
URL url { "http://example.com/_ünicöde_téxt_©"sv };
|
||||
EXPECT(url.is_valid());
|
||||
EXPECT_EQ(url.path(), "/_ünicöde_téxt_©");
|
||||
EXPECT_EQ(url.path(), "/_%C3%BCnic%C3%B6de_t%C3%A9xt_%C2%A9");
|
||||
EXPECT(url.query().is_null());
|
||||
EXPECT(url.fragment().is_null());
|
||||
}
|
||||
|
@ -415,3 +415,10 @@ TEST_CASE(empty_url_with_base_url)
|
|||
EXPECT_EQ(parsed_url.is_valid(), true);
|
||||
EXPECT(base_url.equals(parsed_url));
|
||||
}
|
||||
|
||||
TEST_CASE(google_street_view)
|
||||
{
|
||||
constexpr auto streetview_url = "https://www.google.co.uk/maps/@53.3354159,-1.9573545,3a,75y,121.1h,75.67t/data=!3m7!1e1!3m5!1sSY8xCv17jAX4S7SRdV38hg!2e0!6shttps:%2F%2Fstreetviewpixels-pa.googleapis.com%2Fv1%2Fthumbnail%3Fpanoid%3DSY8xCv17jAX4S7SRdV38hg%26cb_client%3Dmaps_sv.tactile.gps%26w%3D203%26h%3D100%26yaw%3D188.13148%26pitch%3D0%26thumbfov%3D100!7i13312!8i6656";
|
||||
URL url(streetview_url);
|
||||
EXPECT_EQ(url.serialize(), streetview_url);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue