1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:57:35 +00:00

AK: Fix logic error in urldecode() percent-decoding

We also need to append the raw consumed value if *either* of the two
characters after the % isn't a hex digit, not only if *both* aren't.

Fixes #4257.
This commit is contained in:
Linus Groh 2020-11-30 00:28:27 +00:00 committed by Andreas Kling
parent 4c8c149612
commit ba020a5907
2 changed files with 15 additions and 1 deletions

View file

@ -172,9 +172,22 @@ TEST_CASE(data_url)
EXPECT_EQ(url.protocol(), "data");
EXPECT_EQ(url.host(), "");
EXPECT_EQ(url.data_mime_type(), "text/html");
EXPECT_EQ(url.data_payload(), "test");
EXPECT_EQ(url.to_string(), "data:text/html,test");
}
TEST_CASE(data_url_encoded)
{
URL url("data:text/html,Hello%20friends%2C%0X%X0");
EXPECT_EQ(url.is_valid(), true);
EXPECT_EQ(url.protocol(), "data");
EXPECT_EQ(url.host(), "");
EXPECT_EQ(url.data_mime_type(), "text/html");
EXPECT_EQ(url.data_payload(), "Hello friends,%0X%X0");
// FIXME: Surely this should be URL-encoded again?!
EXPECT_EQ(url.to_string(), "data:text/html,Hello friends,%0X%X0");
}
TEST_CASE(data_url_base64_encoded)
{
URL url("data:text/html;base64,test");
@ -182,6 +195,7 @@ TEST_CASE(data_url_base64_encoded)
EXPECT_EQ(url.protocol(), "data");
EXPECT_EQ(url.host(), "");
EXPECT_EQ(url.data_mime_type(), "text/html");
EXPECT_EQ(url.data_payload(), "test");
EXPECT_EQ(url.to_string(), "data:text/html;base64,test");
}