From 213b5aaa47790bab9cd9e0d8dfe055fc22be9d5c Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Wed, 15 May 2024 21:36:44 -0400 Subject: [PATCH 1/2] path setter bug --- tests/basic_tests.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/basic_tests.cpp b/tests/basic_tests.cpp index 79ccbc667..3cbe75e82 100644 --- a/tests/basic_tests.cpp +++ b/tests/basic_tests.cpp @@ -430,4 +430,14 @@ TYPED_TEST(basic_tests, nodejs_undici_2971) { out->get_href(), R"(https://non-ascii-location-header.sys.workers.dev/%EC%95%88%EB%85%95)"); SUCCEED(); +} + +TYPED_TEST(basic_tests, path_setter_bug) { + std::string_view base = "blob:/?"; + auto base_url = ada::parse(base); + ASSERT_TRUE(base_url); + ASSERT_TRUE(base_url->validate()); + ASSERT_TRUE(base_url->set_pathname("//..")); + ASSERT_TRUE(base_url->validate()); + SUCCEED(); } \ No newline at end of file From b965407b8ff1b2d5ff939a1f87f8d1d9b06c83b1 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 16 May 2024 11:53:00 -0400 Subject: [PATCH 2/2] fix: compare // with pathname, not input --- src/url_aggregator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/url_aggregator.cpp b/src/url_aggregator.cpp index c1d06bc5a..2fb1cf5d5 100644 --- a/src/url_aggregator.cpp +++ b/src/url_aggregator.cpp @@ -317,7 +317,7 @@ bool url_aggregator::set_pathname(const std::string_view input) { } clear_pathname(); parse_path(input); - if (checkers::begins_with(input, "//") && !has_authority() && + if (checkers::begins_with(get_pathname(), "//") && !has_authority() && !has_dash_dot()) { buffer.insert(components.pathname_start, "/."); components.pathname_start += 2;