httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cove...@apache.org
Subject svn commit: r1652507 - in /httpd/httpd/trunk: CHANGES modules/mappers/mod_rewrite.c
Date Fri, 16 Jan 2015 19:43:30 GMT
Author: covener
Date: Fri Jan 16 19:43:30 2015
New Revision: 1652507

URL: http://svn.apache.org/r1652507
Log:
mod_rewrite: Improve 'bad flag delimeters' startup error by showing
how the input was tokenized.  PR 56528. 

Submitted By: Edward Lu <Chaosed0 gmail.com>
Committed By: covener


Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/mappers/mod_rewrite.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1652507&r1=1652506&r2=1652507&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Fri Jan 16 19:43:30 2015
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_rewrite: Improve 'bad flag delimeters' startup error by showing
+     how the input was tokenized.  PR 56528. [Edward Lu <Chaosed0 gmail.com>]
+
   *) mod_ssl: Add support for extracting subjectAltName entries of type
      rfc822Name and dNSName into SSL_{CLIENT,SERVER}_SAN_{Email,DNS}_n
      environment variables. Also addresses PR 57207. [Kaspar Brand]

Modified: httpd/httpd/trunk/modules/mappers/mod_rewrite.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/mappers/mod_rewrite.c?rev=1652507&r1=1652506&r2=1652507&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/mappers/mod_rewrite.c (original)
+++ httpd/httpd/trunk/modules/mappers/mod_rewrite.c Fri Jan 16 19:43:30 2015
@@ -2680,7 +2680,7 @@ static apr_status_t rewritelock_remove(v
  * 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;
 
@@ -2705,7 +2705,7 @@ static int parseargline(char *str, char
     }
 
     if (!*str) {
-        return 1;
+        return "bad argument line: at least two arguments required";
     }
     *str++ = '\0';
 
@@ -2731,7 +2731,7 @@ static int parseargline(char *str, char
 
     if (!*str) {
         *a3 = NULL; /* 3rd argument is optional */
-        return 0;
+        return NULL;
     }
     *str++ = '\0';
 
@@ -2741,7 +2741,7 @@ static int parseargline(char *str, char
 
     if (!*str) {
         *a3 = NULL; /* 3rd argument is still optional */
-        return 0;
+        return NULL;
     }
 
     /*
@@ -2760,7 +2760,17 @@ static int parseargline(char *str, char
     }
     *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)
@@ -3185,6 +3195,7 @@ static const char *cmd_parseflagfield(ap
     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";
     }
@@ -3282,9 +3293,10 @@ static const char *cmd_rewritecond(cmd_p
      * 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 */
@@ -3703,9 +3715,10 @@ static const char *cmd_rewriterule(cmd_p
     }
 
     /*  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 */



Mime
View raw message