Skip to content

Commit

Permalink
[PATCH] mod_rewrite: double escaping of query strings in server context
Browse files Browse the repository at this point in the history
(like PR50447, for server context)

Submitted By: Evgeny Kotkov <evgeny.kotkov visualsvn.com>
Committed By: covener




git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1735088 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
covener committed Mar 15, 2016
1 parent 0905aa3 commit c1922e4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-*- coding: utf-8 -*-
Changes with Apache 2.5.0

*) mod_rewrite: Don't implicitly URL-escape the original query string
when no substitution has changed it (like PR50447 but server context)
[Evgeny Kotkov <evgeny.kotkov visualsvn.com>]

*) core: New CGIVar directive can configure REQUEST_URI to represent the
current URI being processed instead of always the original request.
[Jeff Trawick]
Expand Down
21 changes: 19 additions & 2 deletions modules/mappers/mod_rewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -4548,6 +4548,7 @@ static int hook_uri2file(request_rec *r)
unsigned int port;
int rulestatus;
void *skipdata;
const char *oargs;

/*
* retrieve the config structures
Expand Down Expand Up @@ -4597,6 +4598,12 @@ static int hook_uri2file(request_rec *r)
return DECLINED;
}

/*
* remember the original query string for later check, since we don't
* want to apply URL-escaping when no substitution has changed it.
*/
oargs = r->args;

/*
* add the SCRIPT_URL variable to the env. this is a bit complicated
* due to the fact that apache uses subrequests and internal redirects
Expand Down Expand Up @@ -4731,11 +4738,21 @@ static int hook_uri2file(request_rec *r)

/* append the QUERY_STRING part */
if (r->args) {
char *escaped_args = NULL;
int noescape = (rulestatus == ACTION_NOESCAPE ||
(oargs && !strcmp(r->args, oargs)));

r->filename = apr_pstrcat(r->pool, r->filename, "?",
(rulestatus == ACTION_NOESCAPE)
noescape
? r->args
: ap_escape_uri(r->pool, r->args),
: (escaped_args =
ap_escape_uri(r->pool, r->args)),
NULL);

rewritelog((r, 1, NULL, "%s %s to query string for redirect %s",
noescape ? "copying" : "escaping",
r->args ,
noescape ? "" : escaped_args));
}

/* determine HTTP redirect response code */
Expand Down

0 comments on commit c1922e4

Please sign in to comment.