]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
uri-util: Parsing of unreserved syntax erroneously included percent encoding.
authorStephan Bosch <stephan@rename-it.nl>
Sun, 8 May 2016 22:30:14 +0000 (00:30 +0200)
committerGitLab <gitlab@git.dovecot.net>
Mon, 16 May 2016 07:36:48 +0000 (10:36 +0300)
This functionality is currently not used, so no problems would occur.

src/lib/uri-util.c
src/lib/uri-util.h

index 09485c150850f6acf43515f4b9b90fbed70eafd0..eb1cdcb39ba48ecddbf51dc46fc708dc86a46260 100644 (file)
@@ -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) {
index bfb31f0f95065def21d34571cb940626a17d8815..c69fc07d750100dd4860504e412a19239e565265 100644 (file)
@@ -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);