]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Fix ap_construct_url() so that it surrounds IPv6 literal address
authorJeff Trawick <trawick@apache.org>
Tue, 22 Apr 2003 14:51:42 +0000 (14:51 +0000)
committerJeff Trawick <trawick@apache.org>
Tue, 22 Apr 2003 14:51:42 +0000 (14:51 +0000)
strings with [].  This fixes certain types of redirection.

PR:             19207

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

CHANGES
server/core.c

diff --git a/CHANGES b/CHANGES
index 38e182aabb6949cbe17d2dddf2eb9cd4ce82c30d..ea6f5263ca48c2fa10e346add87317b93cafa05c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) Fix ap_construct_url() so that it surrounds IPv6 literal address
+     strings with [].  This fixes certain types of redirection.
+     PR 19207.  [Jeff Trawick]
+
   *) mod_log_config: Add the ability to log the id of the thread 
      processing the request via new %P formats.  [Jeff Trawick]
 
index f2635fb2221b4afb282dc6c6b0aa4630b2e3731d..328933ddab65f325af90b26eb1c93893d78d4a2b 100644 (file)
@@ -885,6 +885,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);
+
+#ifdef 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;
@@ -925,7 +942,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);