You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Gershtein Sergey <sg...@ur.ru> on 2000/05/02 09:14:05 UTC

mod_rewrite/6042: When redirect is forced via mod_rewrite [R] flag the query string gets double-escaped

>Number:         6042
>Category:       mod_rewrite
>Synopsis:       When redirect is forced via mod_rewrite [R] flag the query string gets double-escaped
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Tue May 02 02:00:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     sg@ur.ru
>Release:        1.3.12
>Organization:
apache
>Environment:
FreeBSD dream.mplik.ru 3.4-STABLE FreeBSD 3.4-STABLE #2: Wed Apr 26 12:13:03 YEK
ST 2000     sg@dream.mplik.ru:/usr/src/sys/compile/DREAM  i386                  
>Description:
no core dump
>How-To-Repeat:
RewriteRule /aaa /bbb [R]

GET /aaa?key=%aa 

It's get redirected to /bbb?key=%25aa
>Fix:
Apply the following patch 
also available from http://www1.ekaterinburg.com:8081/leisure/books/tech/mod_rewrite.patch2
---------------------------

*** mod_rewrite.c.orig	Tue May  2 12:41:41 2000
--- mod_rewrite.c	Tue May  2 12:59:35 2000
***************
*** 1164,1170 ****
              /* append the QUERY_STRING part */
              if (r->args != NULL) {
                  r->filename = ap_pstrcat(r->pool, r->filename, "?", 
!                                          ap_escape_uri(r->pool, r->args), NULL);
              }
  
              /* determine HTTP redirect response code */
--- 1164,1170 ----
              /* append the QUERY_STRING part */
              if (r->args != NULL) {
                  r->filename = ap_pstrcat(r->pool, r->filename, "?", 
!                                          r->args, NULL);
              }
  
              /* determine HTTP redirect response code */
***************
*** 1457,1463 ****
              /* append the QUERY_STRING part */
              if (r->args != NULL) {
                  r->filename = ap_pstrcat(r->pool, r->filename, "?", 
!                                          ap_escape_uri(r->pool, r->args), NULL);
              }
  
              /* determine HTTP redirect response code */
--- 1457,1463 ----
              /* append the QUERY_STRING part */
              if (r->args != NULL) {
                  r->filename = ap_pstrcat(r->pool, r->filename, "?", 
!                                          r->args, NULL);
              }
  
              /* determine HTTP redirect response code */
***************
*** 2331,2340 ****
          olduri = ap_pstrdup(r->pool, r->filename);
          *q++ = '\0';
          if (qsappend) {
!             r->args = ap_pstrcat(r->pool, q, "&", r->args, NULL);
          }
          else {
!             r->args = ap_pstrdup(r->pool, q);
          }
          if (strlen(r->args) == 0) {
              r->args = NULL;
--- 2331,2341 ----
          olduri = ap_pstrdup(r->pool, r->filename);
          *q++ = '\0';
          if (qsappend) {
!             r->args = ap_pstrcat(r->pool,
!             	ap_escape_uri(r->pool, q), "&", r->args, NULL);
          }
          else {
!             r->args = ap_pstrdup(r->pool, ap_escape_uri(r->pool, q));
          }
          if (strlen(r->args) == 0) {
              r->args = NULL;
>Release-Note:
>Audit-Trail:
>Unformatted:
 [In order for any reply to be added to the PR database, you need]
 [to include <ap...@Apache.Org> in the Cc line and make sure the]
 [subject line starts with the report component and number, with ]
 [or without any 'Re:' prefixes (such as "general/1098:" or      ]
 ["Re: general/1098:").  If the subject doesn't match this       ]
 [pattern, your message will be misfiled and ignored.  The       ]
 ["apbugs" address is not added to the Cc line of messages from  ]
 [the database automatically because of the potential for mail   ]
 [loops.  If you do not include this Cc, your reply may be ig-   ]
 [nored unless you are responding to an explicit request from a  ]
 [developer.  Reply only with text; DO NOT SEND ATTACHMENTS!     ]