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 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
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:
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
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;
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);