]> granicus.if.org Git - apache/commitdiff
Fix RedirectMatch handling to properly handle URLs with host portions.
authorJustin Erenkrantz <jerenkrantz@apache.org>
Fri, 26 Oct 2001 19:39:51 +0000 (19:39 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Fri, 26 Oct 2001 19:39:51 +0000 (19:39 +0000)
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

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

modules/mappers/mod_alias.c

index 7d6f76444df400d0f6e086a2f89a3af4b0f629c3..314a387b52c3027e553b8e2c210a8db857167bd6 100644 (file)
@@ -338,13 +338,17 @@ static char *try_alias_list(request_rec *r, apr_array_header_t *aliases, int doe
                    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);
                         }
                    }
                }