Mercurial > dovecot > original-hg > dovecot-2.2
changeset 16738:3bd334529536
uri-util: Added support for parsing bare authority URI component (for use in HTTP).
author | Stephan Bosch <stephan@rename-it.nl> |
---|---|
date | Sun, 15 Sep 2013 03:34:06 +0300 |
parents | e83f3d16a31d |
children | a6ed95a30cb1 |
files | src/lib-http/http-url.c src/lib-imap/imap-url.c src/lib/uri-util.c src/lib/uri-util.h |
diffstat | 4 files changed, 21 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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) {
--- 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 */
--- 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;
--- 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,