]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: uri-util - Improve error messages by showing which character is unexpected.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Fri, 15 Oct 2021 20:16:28 +0000 (22:16 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 17 Jan 2022 11:52:09 +0000 (13:52 +0200)
src/lib/uri-util.c

index e4dc419b8aeacf608485371340ff3e7564a07f08..d5f9e3bae5f05435e57bd54957c4815fa75d65b5 100644 (file)
@@ -876,7 +876,9 @@ int uri_parse_path_segment(struct uri_parser *parser, const char **segment_r)
 
        if (parser->cur < parser->end && *parser->cur != '/' &&
            *parser->cur != '?' && *parser->cur != '#') {
-               parser->error = "Path component contains invalid character";
+               parser->error = p_strdup_printf(parser->pool,
+                       "Path component contains invalid character %s",
+                       uri_char_sanitize(*parser->cur));
                return -1;
        }
 
@@ -983,7 +985,9 @@ int uri_parse_path(struct uri_parser *parser,
        }
        if (parser->cur < parser->end &&
            *parser->cur != '?' && *parser->cur != '#') {
-               parser->error = "Path component contains invalid character";
+               parser->error = p_strdup_printf(parser->pool,
+                       "Path component contains invalid character %s",
+                       uri_char_sanitize(*parser->cur));
                return -1;
        }
        return 1;
@@ -1022,7 +1026,9 @@ int uri_parse_query(struct uri_parser *parser, const char **query_r)
        }
 
        if (parser->cur < parser->end && *parser->cur != '#') {
-               parser->error = "Query component contains invalid character";
+               parser->error = p_strdup_printf(parser->pool,
+                       "Query component contains invalid character %s",
+                       uri_char_sanitize(*parser->cur));
                return -1;
        }
 
@@ -1065,7 +1071,9 @@ int uri_parse_fragment(struct uri_parser *parser, const char **fragment_r)
        }
 
        if (parser->cur < parser->end) {
-               parser->error = "Fragment component contains invalid character";
+               parser->error = p_strdup_printf(parser->pool,
+                       "Fragment component contains invalid character %s",
+                       uri_char_sanitize(*parser->cur));
                return -1;
        }