This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 9e31cb26bbc [fix](parse_url) fix `parse_url` is not working in some 
case to extract the HOST  (#25040)
9e31cb26bbc is described below

commit 9e31cb26bbc7b33914d24c34e213efb07f170d06
Author: Guangdong Liu <liug...@gmail.com>
AuthorDate: Mon Oct 9 00:14:58 2023 +0800

    [fix](parse_url) fix `parse_url` is not working in some case to extract the 
HOST  (#25040)
    
    Issue Number: close #24452
---
 be/src/util/url_parser.cpp                    | 5 +++++
 be/test/vec/function/function_string_test.cpp | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/be/src/util/url_parser.cpp b/be/src/util/url_parser.cpp
index 149398b39a4..ddf09b65cbc 100644
--- a/be/src/util/url_parser.cpp
+++ b/be/src/util/url_parser.cpp
@@ -116,6 +116,11 @@ bool UrlParser::parse_url(const StringRef& url, UrlPart 
part, StringRef* result)
         }
 
         StringRef host_start = protocol_end.substring(start_pos);
+        // Find first '?'.
+        int32_t query_start_pos = _s_question_search.search(&host_start);
+        if (query_start_pos > 0) {
+            host_start = host_start.substring(0, query_start_pos);
+        }
         // Find ':' to strip out port.
         int32_t end_pos = _s_colon_search.search(&host_start);
 
diff --git a/be/test/vec/function/function_string_test.cpp 
b/be/test/vec/function/function_string_test.cpp
index 43bfb958cca..e5f4da64eb7 100644
--- a/be/test/vec/function/function_string_test.cpp
+++ b/be/test/vec/function/function_string_test.cpp
@@ -1003,6 +1003,10 @@ TEST(function_string_test, function_parse_url_test) {
                 {{std::string("facebook.com/path/p1"), std::string("HOST")}, 
{Null()}},
                 {{std::string("http://fb.com/path/p1.p?q=1#f";), 
std::string("HOST")},
                  {std::string("fb.com")}},
+                
{{std::string("https://www.facebook.com/aa/bb?returnpage=https://www.facebook.com/";
+                              "aa/bb/cc"),
+                  std::string("HOST")},
+                 {std::string("www.facebook.com")}},
                 {{std::string("http://facebook.com/path/p1.php?query=1";), 
std::string("AUTHORITY")},
                  {std::string("facebook.com")}},
                 {{std::string("http://facebook.com/path/p1.php?query=1";), 
std::string("authority")},


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to