From: Yann Ylavic Date: Mon, 11 May 2015 10:02:04 +0000 (+0000) Subject: Merge r900022 from trunk. X-Git-Tag: 2.2.30~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6328aa99050ee59d17aeb65a18f3fc7caef8f7f9;p=thirdparty%2Fapache%2Fhttpd.git Merge r900022 from trunk. Turn static function get_server_name_for_url() into public function ap_get_server_name_for_url() and use it where appropriate. This fixes mod_rewrite generating invalid URLs for redirects to IPv6 literal addresses. Committed by: sf Reviewed by: jailletc36, ylavic, rjung Backported by: ylavic git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1678714 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 6c0c49f771d..05223aaf688 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,11 @@ -*- coding: utf-8 -*- Changes with Apache 2.2.30 + *) Turn static function get_server_name_for_url() into public + ap_get_server_name_for_url() and use it where appropriate. This + fixes mod_rewrite generating invalid URLs for redirects to IPv6 + literal addresses. PR 52831 [Stefan Fritsch] + *) dav_validate_request: avoid validating locks and ETags when there are no If headers providing them on a resource we aren't modifying. [Ben Reser] diff --git a/STATUS b/STATUS index 3127c7ca27e..64925736db3 100644 --- a/STATUS +++ b/STATUS @@ -101,15 +101,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_rewrite: Turn static function get_server_name_for_url() into public - ap_get_server_name_for_url() and use it where appropriate. This - fixes mod_rewrite generating invalid URLs for redirects to IPv6 - literal addresses. - Fixed in 2.3.5 five years ago but repported later in 2.2.x (PR 52831) - trunk patch: http://svn.apache.org/r900022 - 2.4.x patch: http://people.apache.org/~jailletc36/PR52831.patch - +1: jailletc36, ylavic, rjung - PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 20586967438..975e951d9a9 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -154,6 +154,7 @@ * 20051115.34 (2.2.28) Add ap_copy_scoreboard_worker() * 20051115.35 (2.2.28) Add SSL reusable SNI to mod_proxy.h's proxy_conn_rec * 20051115.36 (2.2.28) Add r->trailers_{in,out} + * 20051115.37 (2.2.30) Add ap_get_server_name_for_url() */ #define MODULE_MAGIC_COOKIE 0x41503232UL /* "AP22" */ @@ -161,7 +162,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20051115 #endif -#define MODULE_MAGIC_NUMBER_MINOR 36 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 37 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/http_core.h b/include/http_core.h index 1aa9bd9b5a9..c397962bd42 100644 --- a/include/http_core.h +++ b/include/http_core.h @@ -227,6 +227,15 @@ AP_DECLARE(char *) ap_construct_url(apr_pool_t *p, const char *uri, request_rec */ AP_DECLARE(const char *) ap_get_server_name(request_rec *r); +/** + * 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]"). + * @param r The current request + * @return the server name + */ +AP_DECLARE(const char *) ap_get_server_name_for_url(request_rec *r); + /** * Get the current server port * @param r The current request diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index d3209b44954..e1afe6f43c0 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -860,7 +860,7 @@ static void fully_qualify_uri(request_rec *r) char *thisport; int port; - thisserver = ap_get_server_name(r); + thisserver = ap_get_server_name_for_url(r); port = ap_get_server_port(r); thisport = ap_is_default_port(port, r) ? "" @@ -4353,7 +4353,7 @@ static int hook_uri2file(request_rec *r) */ /* add the canonical URI of this URL */ - thisserver = ap_get_server_name(r); + thisserver = ap_get_server_name_for_url(r); port = ap_get_server_port(r); if (ap_is_default_port(port, r)) { thisport = ""; diff --git a/server/core.c b/server/core.c index 07e099715d5..4f2df326ba6 100644 --- a/server/core.c +++ b/server/core.c @@ -973,7 +973,7 @@ AP_DECLARE(const char *) ap_get_server_name(request_rec *r) * 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) +AP_DECLARE(const char *) ap_get_server_name_for_url(request_rec *r) { const char *plain_server_name = ap_get_server_name(r); @@ -1036,7 +1036,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 = get_server_name_for_url(r); + const char *host = ap_get_server_name_for_url(r); if (ap_is_default_port(port, r)) { return apr_pstrcat(p, ap_http_scheme(r), "://", host, uri, NULL);