ASF Bugzilla – Attachment 31685 Details for
Bug 56528
"bad flags delimiter" - improve helpfulness
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Improve error reporting in mod_rewrite
bad_flag_delimiters.patch (text/plain), 3.37 KB, created by
Edward Lu
on 2014-06-03 13:53:07 UTC
(
hide
)
Description:
Improve error reporting in mod_rewrite
Filename:
MIME Type:
Creator:
Edward Lu
Created:
2014-06-03 13:53:07 UTC
Size:
3.37 KB
patch
obsolete
>diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c >index 7122cb4..8e3bc7a 100644 >--- a/modules/mappers/mod_rewrite.c >+++ b/modules/mappers/mod_rewrite.c >@@ -2657,7 +2657,7 @@ static apr_status_t rewritelock_remove(void *data) > * 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; > >@@ -2682,7 +2682,7 @@ static int parseargline(char *str, char **a1, char **a2, char **a3) > } > > if (!*str) { >- return 1; >+ return "bad argument line: at least two arguments required"; > } > *str++ = '\0'; > >@@ -2708,7 +2708,7 @@ static int parseargline(char *str, char **a1, char **a2, char **a3) > > if (!*str) { > *a3 = NULL; /* 3rd argument is optional */ >- return 0; >+ return NULL; > } > *str++ = '\0'; > >@@ -2718,7 +2718,7 @@ static int parseargline(char *str, char **a1, char **a2, char **a3) > > if (!*str) { > *a3 = NULL; /* 3rd argument is still optional */ >- return 0; >+ return NULL; > } > > /* >@@ -2737,7 +2737,17 @@ static int parseargline(char *str, char **a1, char **a2, char **a3) > } > *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) >@@ -3159,6 +3169,7 @@ static const char *cmd_parseflagfield(apr_pool_t *p, void *cfg, char *key, > 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"; > } >@@ -3256,9 +3267,10 @@ static const char *cmd_rewritecond(cmd_parms *cmd, void *in_dconf, > * 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 */ >@@ -3671,9 +3683,10 @@ static const char *cmd_rewriterule(cmd_parms *cmd, void *in_dconf, > } > > /* 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 */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 56528
:
31627
| 31685