dovecot-2.2: uri-util: Added support for parsing bare authority ...

dovecot at dovecot.org dovecot at dovecot.org
Sun Sep 15 03:38:25 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/3bd334529536
changeset: 16738:3bd334529536
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sun Sep 15 03:34:06 2013 +0300
description:
uri-util: Added support for parsing bare authority URI component (for use in HTTP).

diffstat:

 src/lib-http/http-url.c |   2 +-
 src/lib-imap/imap-url.c |   2 +-
 src/lib/uri-util.c      |  24 +++++++++++++++---------
 src/lib/uri-util.h      |   5 ++++-
 4 files changed, 21 insertions(+), 12 deletions(-)

diffs (87 lines):

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,


More information about the dovecot-cvs mailing list