for (p += 6; *p != '\0'; p++) {
if (*p == ';' || *p == ':') {
parser->error = t_strdup_printf(
- "Stray '%c' in userinfo `%s'", *p, auth.enc_userinfo);
+ "Stray %s in userinfo `%s'",
+ uri_char_sanitize(*p),
+ auth.enc_userinfo);
return -1;
}
}
if (value < 0) {
parser->error = p_strdup_printf(
parser->pool,
- "Expecting hex digit after '%%', but found '%c'", **p);
+ "Expecting hex digit after '%%', but found %s",
+ uri_char_sanitize(**p));
return -1;
}
if (value < 0) {
parser->error = p_strdup_printf(
parser->pool,
- "Expecting hex digit after '%%%c', but found '%c'",
- *((*p)-1), **p);
+ "Expecting hex digit after '%%%c', but found %s",
+ *((*p)-1), uri_char_sanitize(**p));
return -1;
}
bool allow_pct_nul:1;
};
+static inline const char *uri_char_sanitize(unsigned char c)
+{
+ if (c >= 0x20 && c < 0x7F)
+ return t_strdup_printf("'%c'", c);
+ return t_strdup_printf("<0x%02x>", c);
+}
+
/* Parse one instance of percent encoding. Returns 1 for success, 0 if none is
present at the current parser position, and -1 in case of error. The decoded
character is returned in ch_r upon success. */