]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: http-url - Split off http_url_parse_unknown_scheme() from http_url_do_parse().
authorStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 30 Oct 2019 07:58:00 +0000 (08:58 +0100)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 6 Nov 2019 20:34:08 +0000 (20:34 +0000)
src/lib-http/http-url.c

index 83de64e62717081d6bfc7e68b43001ab031a0275..dc6f197a13a634e78f21d76432ba23afe5fc1725 100644 (file)
@@ -27,6 +27,28 @@ struct http_url_parser {
        bool request_target:1;
 };
 
+static bool http_url_parse_authority_form(struct http_url_parser *url_parser);
+
+static bool http_url_parse_unknown_scheme(struct http_url_parser *url_parser)
+{
+       struct uri_parser *parser = &url_parser->parser;
+
+       if (url_parser->request_target) {
+               /* Valid as non-HTTP scheme, but also try to parse as authority
+                */
+               parser->cur = parser->begin;
+               if (!http_url_parse_authority_form(url_parser)) {
+                       /* indicate non-http-url */
+                       url_parser->url = NULL;
+                       url_parser->req_format =
+                               HTTP_REQUEST_TARGET_FORMAT_ABSOLUTE;
+               }
+               return TRUE;
+       }
+       parser->error = "Not an HTTP URL";
+       return FALSE;
+}
+
 static bool
 http_url_parse_userinfo(struct http_url_parser *url_parser,
                        struct uri_authority *auth,
@@ -186,21 +208,7 @@ static bool http_url_do_parse(struct http_url_parser *url_parser)
                                if (url != NULL)
                                        url->have_ssl = TRUE;
                        } else if (strcasecmp(scheme, "http") != 0) {
-                               if (url_parser->request_target) {
-                                       /* Valid as non-HTTP scheme, but also
-                                          try to parse as authority */
-                                       parser->cur = parser->begin;
-                                       if (!http_url_parse_authority_form(
-                                               url_parser)) {
-                                               /* indicate non-http-url */
-                                               url_parser->url = NULL;
-                                               url_parser->req_format =
-                                                       HTTP_REQUEST_TARGET_FORMAT_ABSOLUTE;
-                                       }
-                                       return TRUE;
-                               }
-                               parser->error = "Not an HTTP URL";
-                               return FALSE;
+                               return http_url_parse_unknown_scheme(url_parser);
                        }
                        relative = FALSE;
                        have_scheme = TRUE;