From: Stephan Bosch Date: Fri, 15 Oct 2021 20:16:28 +0000 (+0200) Subject: lib: uri-util - Improve error messages by showing which character is unexpected. X-Git-Tag: 2.4.0~4708 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=49fd6be9ff6aa605c43ee4cd52573b3693bc547b;p=thirdparty%2Fdovecot%2Fcore.git lib: uri-util - Improve error messages by showing which character is unexpected. --- diff --git a/src/lib/uri-util.c b/src/lib/uri-util.c index e4dc419b8a..d5f9e3bae5 100644 --- a/src/lib/uri-util.c +++ b/src/lib/uri-util.c @@ -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; }