]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
merge this fix from 2.1-dev:
authorJeff Trawick <trawick@apache.org>
Tue, 13 May 2003 16:01:04 +0000 (16:01 +0000)
committerJeff Trawick <trawick@apache.org>
Tue, 13 May 2003 16:01:04 +0000 (16:01 +0000)
Fix ap_construct_url() so that it surrounds IPv6 literal address
strings with [].  This fixes certain types of redirection.

PR:           19207
Reviewed by:  Bill Stoddard, Thom May

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

CHANGES
STATUS
server/core.c

diff --git a/CHANGES b/CHANGES
index fd86e92b0612212ca43c69f5e13f18c46e617aaa..b9eb9cef455849c6fabc12a0a99528141d6665d5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,9 @@
 Changes with Apache 2.0.46
 
+  *) Fix ap_construct_url() so that it surrounds IPv6 literal address
+     strings with [].  This fixes certain types of redirection.
+     PR 19207.  [Jeff Trawick]
+
   *) forward port of buffer overflow fixes for htdigest. [Thom May]
 
   *) Added AllowEncodedSlashes directive to permit control of whether
diff --git a/STATUS b/STATUS
index 82cde050c5634629bc241db42932935bbbc48ba6..3cf28e077e84967567b54cc0ff6fce18bc589c2c 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -1,5 +1,5 @@
 APACHE 2.0 STATUS:                                              -*-text-*-
-Last modified at [$Date: 2003/05/13 15:51:04 $]
+Last modified at [$Date: 2003/05/13 16:01:03 $]
 
 Release:
 
@@ -217,18 +217,6 @@ PATCHES TO PORT FROM 2.1
       modules/mappers/config9.m4 r1.16
       +1: trawick, nd, stoddard
 
-    * Fix ap_construct_url() so that it surrounds IPv6 literal address
-      strings with [].  This fixes certain types of redirection.
-      PR 19207.
-      server/core.c r1.232
-      +1: nd
-      Oops!  While r1.232 isn't actually broken functionally, it will 
-      do an unnecessary string search with non-IPv6 builds because of a 
-      bogus check for IPv6 capability.
-      server/core.c r1.232+r1.235
-      +1: trawick, stoddard, thommay
-
-
     * Hook mod_rewrite's type checker before mod_mime's one. That way the
       RewriteRule [T=...] Flag should work as expected now. PR 19626.
       modules/mappers/mod_rewrite.c r1.150
index baee8f8325cd48d8a522c6300d3d4b5681a5cd82..bc940dc18c37f582d079bfc0cb6fd03a5b9919d2 100644 (file)
@@ -893,6 +893,23 @@ AP_DECLARE(const char *) ap_get_server_name(request_rec *r)
     return r->server->server_hostname;
 }
 
+/*
+ * Get the current server name from the request for the purposes
+ * of using in a URL.  If the server name is an IPv6 literal
+ * address, it will be returned in URL format (e.g., "[fe80::1]").
+ */
+static const char *get_server_name_for_url(request_rec *r)
+{
+    const char *plain_server_name = ap_get_server_name(r);
+
+#if APR_HAVE_IPV6
+    if (ap_strchr_c(plain_server_name, ':')) { /* IPv6 literal? */
+        return apr_psprintf(r->pool, "[%s]", plain_server_name);
+    }
+#endif
+    return plain_server_name;
+}
+
 AP_DECLARE(apr_port_t) ap_get_server_port(const request_rec *r)
 {
     apr_port_t port;
@@ -933,7 +950,7 @@ AP_DECLARE(char *) ap_construct_url(apr_pool_t *p, const char *uri,
                                     request_rec *r)
 {
     unsigned port = ap_get_server_port(r);
-    const char *host = ap_get_server_name(r);
+    const char *host = get_server_name_for_url(r);
 
     if (ap_is_default_port(port, r)) {
         return apr_pstrcat(p, ap_http_method(r), "://", host, uri, NULL);