From: Stephan Bosch Date: Sun, 8 May 2016 22:30:14 +0000 (+0200) Subject: uri-util: Parsing of unreserved syntax erroneously included percent encoding. X-Git-Tag: 2.3.0.rc1~3757 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b7e953d7eecd18f1d0de701cc181e8830d8167b1;p=thirdparty%2Fdovecot%2Fcore.git uri-util: Parsing of unreserved syntax erroneously included percent encoding. This functionality is currently not used, so no problems would occur. --- diff --git a/src/lib/uri-util.c b/src/lib/uri-util.c index 09485c1508..eb1cdcb39b 100644 --- a/src/lib/uri-util.c +++ b/src/lib/uri-util.c @@ -143,11 +143,6 @@ int uri_parse_pct_encoded(struct uri_parser *parser, static int uri_parse_unreserved_char(struct uri_parser *parser, unsigned char *ch_r) { - int ret; - - if ((ret=uri_parse_pct_encoded(parser, ch_r)) != 0) - return ret; - if ((*parser->cur & 0x80) != 0) return 0; @@ -180,6 +175,30 @@ int uri_parse_unreserved(struct uri_parser *parser, string_t *part) return len > 0 ? 1 : 0; } +int uri_parse_unreserved_pct(struct uri_parser *parser, string_t *part) +{ + int len = 0; + + while (parser->cur < parser->end) { + int ret; + unsigned char ch = 0; + + if ((ret=uri_parse_pct_encoded(parser, &ch)) < 0) + return -1; + else if (ret == 0 && + (ret=uri_parse_unreserved_char(parser, &ch)) < 0) + return -1; + if (ret == 0) + break; + + if (part != NULL) + str_append_c(part, ch); + len++; + } + + return len > 0 ? 1 : 0; +} + bool uri_data_decode(struct uri_parser *parser, const char *data, const char *until, const char **decoded_r) { @@ -350,7 +369,10 @@ uri_parse_reg_name(struct uri_parser *parser, unsigned char c; /* unreserved / pct-encoded */ - if ((ret = uri_parse_unreserved_char(parser, &c)) < 0) + if ((ret=uri_parse_pct_encoded(parser, &c)) < 0) + return -1; + else if (ret == 0 && + (ret=uri_parse_unreserved_char(parser, &c)) < 0) return -1; if (ret > 0) { diff --git a/src/lib/uri-util.h b/src/lib/uri-util.h index bfb31f0f95..c69fc07d75 100644 --- a/src/lib/uri-util.h +++ b/src/lib/uri-util.h @@ -27,7 +27,9 @@ struct uri_parser { int uri_parse_pct_encoded(struct uri_parser *parser, unsigned char *ch_r); + int uri_parse_unreserved(struct uri_parser *parser, string_t *part); +int uri_parse_unreserved_pct(struct uri_parser *parser, string_t *part); bool uri_data_decode(struct uri_parser *parser, const char *data, const char *until, const char **decoded_r) ATTR_NULL(3);