]> granicus.if.org Git - apache/commitdiff
treat a rewriterule substitution that expands to "-" as if the rule
authorEric Covener <covener@apache.org>
Thu, 2 Feb 2012 15:43:41 +0000 (15:43 +0000)
committerEric Covener <covener@apache.org>
Thu, 2 Feb 2012 15:43:41 +0000 (15:43 +0000)
had a literal "-".

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1239679 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index fcb3cfd4ad85894fd8c09fcc1b24f8e946886142..00dc082104afbbca0093655a6128ec9e25738806 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_rewrite: Treat a RewriteRule substitution that expands to
+     "-" to behave as if a literal "-" was used in the RewriteRule
+     (no substitution). [Eric Covener]
+
   *) mod_authnz_ldap: Don't try a potentially expensive nested groups
      search before exhausting all AuthLDAPGroupAttribute checks on the
      current group. PR52464 [Eric Covener]
index 8f5d3972ed19aa6d8107c34f03c1224c29dfef71..2e285bbeb850ae1801eb3d0ad0b051196057cab2 100644 (file)
@@ -3909,6 +3909,7 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
     char *newuri = NULL;
     request_rec *r = ctx->r;
     int is_proxyreq = 0;
+    int force_no_sub = 0;
 
     ctx->uri = r->filename;
 
@@ -4022,6 +4023,11 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
         newuri = do_expand(p->output, ctx, p);
         rewritelog((r, 2, ctx->perdir, "rewrite '%s' -> '%s'", ctx->uri,
                     newuri));
+        /* Allow a substitution to resolve to "-" and act like a literal "-" */
+        if (newuri && *newuri == '-' && !newuri[1]) {
+            newuri = NULL;
+            force_no_sub = 1; 
+        }
     }
 
     /* expand [E=var:val] and [CO=<cookie>] */
@@ -4029,7 +4035,7 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
     do_expand_cookie(p->cookie, ctx);
 
     /* non-substitution rules ('RewriteRule <pat> -') end here. */
-    if (p->flags & RULEFLAG_NOSUB) {
+    if (p->flags & RULEFLAG_NOSUB || force_no_sub) {
         force_type_handler(p, ctx);
 
         if (p->flags & RULEFLAG_STATUS) {