You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by je...@apache.org on 2001/10/26 21:39:51 UTC

cvs commit: httpd-2.0/modules/mappers mod_alias.c

jerenkrantz    01/10/26 12:39:51

  Modified:    modules/mappers mod_alias.c
  Log:
  Fix RedirectMatch handling to properly handle URLs with host portions.
  Previously, we would segfault if no path is specified (case 1 below).
  We would also ignore any host and scheme portion of the URL (which is
  how we specify it on daedalus), so restore that capability.
  
  The query strings will still not be escaped (standards cops can
  determine if this is correct behavior).
  
  The following directives now work as expected:
  RedirectMatch /jakarta1(.*) http://jakarta.apache.org$1
  RedirectMatch /jakarta2(.*) http://jakarta.apache.org/dist$1
  RedirectMatch /jakarta3(.*) http://jakarta.apache.org/dist$1?bar=foo
  RedirectMatch /jakarta4(.*) http://jakarta.apache.org/dist$1?bar=foo#spaz
  
  Revision  Changes    Path
  1.32      +9 -5      httpd-2.0/modules/mappers/mod_alias.c
  
  Index: mod_alias.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_alias.c,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- mod_alias.c	2001/08/23 18:49:55	1.31
  +++ mod_alias.c	2001/10/26 19:39:51	1.32
  @@ -338,13 +338,17 @@
   		    if (found && doesc) {
                           apr_uri_t uri;
                           apr_uri_parse(r->pool, found, &uri);
  -			found = ap_escape_uri(r->pool, uri.path);
  +                        /* Do not escape the query string or fragment. */
  +                        found = apr_uri_unparse(r->pool, &uri, 
  +                                                APR_URI_UNP_OMITQUERY);
  +                        found = ap_escape_uri(r->pool, found);
                           if (uri.query) {
  -                            found = apr_pstrcat(r->pool, found, "?", uri.query, NULL);
  +                            found = apr_pstrcat(r->pool, found, "?", 
  +                                                uri.query, NULL);
                           }
  -                        else if (uri.fragment) {
  -                            found = apr_pstrcat(r->pool, found, "#", uri.fragment, NULL);
  -
  +                        if (uri.fragment) {
  +                            found = apr_pstrcat(r->pool, found, "#", 
  +                                                uri.fragment, NULL);
                           }
   		    }
   		}