* XXX: what an inclined parser. Seems we have to leave it so
* for backwards compat. *sigh*
*/
-static int parseargline(char *str, char **a1, char **a2, char **a3)
+static char *parseargline(apr_pool_t *p, char *str, char **a1, char **a2, char **a3)
{
char quote;
}
if (!*str) {
- return 1;
+ return "bad argument line: at least two arguments required";
}
*str++ = '\0';
if (!*str) {
*a3 = NULL; /* 3rd argument is optional */
- return 0;
+ return NULL;
}
*str++ = '\0';
if (!*str) {
*a3 = NULL; /* 3rd argument is still optional */
- return 0;
+ return NULL;
}
/*
}
*str = '\0';
- return 0;
+ if (**a3 != '[') {
+ return apr_psprintf(p, "bad flag delimiters: third argument must begin "
+ "with '[' but found '%c' - too many arguments or rogue "
+ "whitespace?", **a3);
+ }
+ else if ((*a3)[strlen(*a3)-1] != ']') {
+ return apr_psprintf(p, "bad flag delimiters: third argument must end "
+ "with ']' but found '%c' - unintended whitespace within the "
+ "flags definition?", (*a3)[strlen(*a3)-1]);
+ }
+ return NULL;
}
static void *config_server_create(apr_pool_t *p, server_rec *s)
const char *err;
endp = key + strlen(key) - 1;
+ /* This should have been checked before, but just in case... */
if (*key != '[' || *endp != ']') {
return "bad flag delimiters";
}
* of the argument line. So we can use a1 .. a3 without
* copying them again.
*/
- if (parseargline(str, &a1, &a2, &a3)) {
- return apr_pstrcat(cmd->pool, "RewriteCond: bad argument line '", str,
- "'", NULL);
+ if ((err = parseargline(cmd->pool, str, &a1, &a2, &a3))) {
+ return apr_psprintf(cmd->pool, "RewriteCond: %s "
+ "(TestString=%s, CondPattern=%s, flags=%s)",
+ err, a1, a2, a3);
}
/* arg1: the input string */
}
/* parse the argument line ourself */
- if (parseargline(str, &a1, &a2, &a3)) {
- return apr_pstrcat(cmd->pool, "RewriteRule: bad argument line '", str,
- "'", NULL);
+ if ((err = parseargline(cmd->pool, str, &a1, &a2, &a3))) {
+ return apr_psprintf(cmd->pool, "RewriteRule: %s "
+ "(pattern='%s', substitution='%s', flags='%s')",
+ err, a1, a2, a3);
}
/* arg3: optional flags field */