open-telemetry / opentelemetry-cpp

The OpenTelemetry C++ Client
https://opentelemetry.io/
Apache License 2.0
889 stars 423 forks source link

URL parser throws an exception #3138

Open marcalff opened 1 day ago

marcalff commented 1 day ago

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
github-actions[bot] commented 20 hours ago

This issue is available for anyone to work on. Make sure to reference this issue in your pull request. :sparkles: Thank you for your contribution! :sparkles: