Skip to content

URL parser throws an exception #3138

@marcalff

Description

@marcalff

When parsing https://https://example.com/some/path, the URL parser throws an exception.

The expected result is to return a parse error instead.

diff --git a/ext/test/http/url_parser_test.cc b/ext/test/http/url_parser_test.cc
index aceb4396..118320e4 100644
--- a/ext/test/http/url_parser_test.cc
+++ b/ext/test/http/url_parser_test.cc
@@ -18,6 +18,13 @@ inline const char *BoolToString(bool b)
 TEST(UrlParserTests, BasicTests)
 {
   std::map<std::string, std::map<std::string, std::string>> urls_map{
+      {"https://https://example.com/some/path",
+       {{"host", "www.abc.com"},
+        {"port", "80"},
+        {"scheme", "http"},
+        {"path", "/"},
+        {"query", ""},
+        {"success", "true"}}},
       {"www.abc.com",
        {{"host", "www.abc.com"},
         {"port", "80"},
[malff@malff-desktop build-otelcpp-abiv1]$ ./ext/test/http/url_parser_test
Running main() from /builddir/build/BUILD/googletest-release-1.11.0/googletest/src/gtest_main.cc
[==========] Running 2 tests from 2 test suites.
[----------] Global test environment set-up.
[----------] 1 test from UrlParserTests
[ RUN      ] UrlParserTests.BasicTests
unknown file: Failure
C++ exception with description "stoi" thrown in the test body.
[  FAILED  ] UrlParserTests.BasicTests (0 ms)
[----------] 1 test from UrlParserTests (0 ms total)

[----------] 1 test from UrlDecoderTests
[ RUN      ] UrlDecoderTests.BasicTests
[       OK ] UrlDecoderTests.BasicTests (0 ms)
[----------] 1 test from UrlDecoderTests (0 ms total)

[----------] Global test environment tear-down
[==========] 2 tests from 2 test suites ran. (0 ms total)
[  PASSED  ] 1 test.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] UrlParserTests.BasicTests

 1 FAILED TEST

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedGood for taking. Extra help will be provided by maintainerstriage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions