]> granicus.if.org Git - apache/commitdiff
* modules/mappers/mod_rewrite.c (apply_rewrite_rule): When evaluating
authorJoe Orton <jorton@apache.org>
Mon, 23 Mar 2009 15:59:36 +0000 (15:59 +0000)
committerJoe Orton <jorton@apache.org>
Mon, 23 Mar 2009 15:59:36 +0000 (15:59 +0000)
  a proxy rule in directory context, do escape the filename by
  default, since mod_proxy will not escape in that case due to the
  (deliberate) fixup hook ordering.

Thanks to: rpluem
PR: 46428

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

modules/mappers/mod_rewrite.c

index 04aa460b0aab06f2925a3e5b462d5d81cefba691..4d4eec35ef43cef7c2921bf3781e3b30af04d2e2 100644 (file)
@@ -4083,7 +4083,20 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
      * ourself).
      */
     if (p->flags & RULEFLAG_PROXY) {
-        /* PR#39746: Escaping things here gets repeated in mod_proxy */
+        /* For rules evaluated in server context, the mod_proxy fixup
+         * hook can be relied upon to escape the URI as and when
+         * necessary, since it occurs later.  If in directory context,
+         * the ordering of the fixup hooks is forced such that
+         * mod_proxy comes first, so the URI must be escaped here
+         * instead.  See PR 39746, 46428, and other headaches. */
+        if (ctx->perdir && (p->flags & RULEFLAG_NOESCAPE) == 0) {
+            char *old_filename = r->filename;
+            
+            r->filename = ap_escape_uri(r->pool, r->filename);
+            rewritelog((r, 2, ctx->perdir, "escaped URI in per-dir context "
+                        "for proxy, %s -> %s", old_filename, r->filename));
+        }
+        
         fully_qualify_uri(r);
 
         rewritelog((r, 2, ctx->perdir, "forcing proxy-throughput with %s",