# HG changeset patch # User Stephan Bosch # Date 1379205246 -10800 # Node ID 3bd334529536970813869d1364ed919ae7638438 # Parent e83f3d16a31defd7c75c78bc8c2b98c7ecea532f uri-util: Added support for parsing bare authority URI component (for use in HTTP). diff -r e83f3d16a31d -r 3bd334529536 src/lib-http/http-url.c --- a/src/lib-http/http-url.c Sun Sep 15 03:33:44 2013 +0300 +++ b/src/lib-http/http-url.c Sun Sep 15 03:34:06 2013 +0300 @@ -69,7 +69,7 @@ } /* "//" 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) { diff -r e83f3d16a31d -r 3bd334529536 src/lib-imap/imap-url.c --- a/src/lib-imap/imap-url.c Sun Sep 15 03:33:44 2013 +0300 +++ b/src/lib-imap/imap-url.c Sun Sep 15 03:34:06 2013 +0300 @@ -221,7 +221,7 @@ */ /* "//" 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 */ diff -r e83f3d16a31d -r 3bd334529536 src/lib/uri-util.c --- a/src/lib/uri-util.c Sun Sep 15 03:33:44 2013 +0300 +++ b/src/lib/uri-util.c Sun Sep 15 03:34:06 2013 +0300 @@ -509,22 +509,16 @@ 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 @@ 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; diff -r e83f3d16a31d -r 3bd334529536 src/lib/uri-util.h --- a/src/lib/uri-util.h Sun Sep 15 03:33:44 2013 +0300 +++ b/src/lib/uri-util.h Sun Sep 15 03:34:06 2013 +0300 @@ -35,7 +35,10 @@ 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,