]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
uri-util: Added support for parsing bare authority URI component (for use in HTTP).
authorStephan Bosch <stephan@rename-it.nl>
Sun, 15 Sep 2013 00:34:06 +0000 (03:34 +0300)
committerStephan Bosch <stephan@rename-it.nl>
Sun, 15 Sep 2013 00:34:06 +0000 (03:34 +0300)
src/lib-http/http-url.c
src/lib-imap/imap-url.c
src/lib/uri-util.c
src/lib/uri-util.h

index 1574feedd47b533db8f674b316d3afeac8d44272..80a9ae39d404c92c87686b0396023ca3516a6495 100644 (file)
@@ -69,7 +69,7 @@ static bool http_url_do_parse(struct http_url_parser *url_parser)
        }
 
        /* "//" host [ ":" port ] */
-       if ((ret = uri_parse_authority(parser, &auth)) < 0)
+       if ((ret = uri_parse_slashslash_authority(parser, &auth)) < 0)
                return FALSE;
        if (ret > 0) {
                if (auth.enc_userinfo != NULL) {
index a97208a94108d9ee3ade7c43a58052636c56fa35..911d1d26be8412d547ebbbfbbaae76aed121a79a 100644 (file)
@@ -221,7 +221,7 @@ static int imap_url_parse_iserver(struct imap_url_parser *url_parser)
         */
 
        /* "//" iserver */
-       if ((ret = uri_parse_authority(parser, &auth)) <= 0)
+       if ((ret = uri_parse_slashslash_authority(parser, &auth)) <= 0)
                return ret;
 
        /* iuserinfo        = enc-user [iauth] / [enc-user] iauth */
index 7b224c2ac4a1cb2a39486d94d76b2b8632bd006e..2bc0dbbd080387a3105fae5998ca397459ac873e 100644 (file)
@@ -509,22 +509,16 @@ static int uri_parse_port(struct uri_parser *parser, struct uri_authority *auth)
        return 0;
 }
 
-int uri_parse_authority(struct uri_parser *parser, struct uri_authority *auth)
+int uri_parse_authority(struct uri_parser *parser,
+       struct uri_authority *auth)
 {
        const unsigned char *p;
        int ret;
        
-       /* hier-part     = "//" authority {...}
-        * relative-part = "//" authority {...}
+       /*
         * authority     = [ userinfo "@" ] host [ ":" port ]
         */
 
-       /* Parse "//" as part of authority */
-       if ((parser->end - parser->cur) <= 2 || parser->cur[0] != '/' ||
-           parser->cur[1] != '/')
-               return 0;
-       parser->cur += 2;
-
        if (auth != NULL)
                memset(auth, 0, sizeof(*auth));
 
@@ -566,6 +560,18 @@ int uri_parse_authority(struct uri_parser *parser, struct uri_authority *auth)
        return 1;
 }
 
+int uri_parse_slashslash_authority(struct uri_parser *parser,
+       struct uri_authority *auth)
+{
+       /* "//" authority */
+
+       if ((parser->end - parser->cur) <= 2 || parser->cur[0] != '/' ||
+           parser->cur[1] != '/')
+               return 0;
+
+       return uri_parse_authority(parser, auth);
+}
+
 int uri_parse_path_segment(struct uri_parser *parser, const char **segment_r)
 {
        const unsigned char *p = parser->cur;
index c850365ea60858b66502efbf39392e73e22ec46e..e64c8ebabe51c6e0a39c734655b249138ae2fec8 100644 (file)
@@ -35,7 +35,10 @@ bool uri_data_decode(struct uri_parser *parser, const char *data,
 
 int uri_cut_scheme(const char **uri_p, const char **scheme_r);
 int uri_parse_scheme(struct uri_parser *parser, const char **scheme_r);
-int uri_parse_authority(struct uri_parser *parser, struct uri_authority *auth);
+int uri_parse_authority(struct uri_parser *parser,
+       struct uri_authority *auth);
+int uri_parse_slashslash_authority(struct uri_parser *parser,
+       struct uri_authority *auth);
 
 int uri_parse_path_segment(struct uri_parser *parser, const char **segment_r);
 int uri_parse_path(struct uri_parser *parser, int *relative_r,