From: Jim Jagielski Date: Mon, 6 Jul 2009 16:55:28 +0000 (+0000) Subject: * mod_alias: Ensure Redirect emits HTTP-compliant URLs. X-Git-Tag: 2.2.12~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60f5b1b0eb133324fd7e15df9f449caeb43dfd52;p=thirdparty%2Fapache%2Fhttpd.git * mod_alias: Ensure Redirect emits HTTP-compliant URLs. PR 44020 trunk patch: http://svn.apache.org/viewvc?view=rev&rev=785575 2.2.x patch: http://people.apache.org/~rpluem/patches/foreign_patches/niq_44020.diff NOTE: I'm recommending different versions because the trunk patch is too strict for a stable line and may "break" broken configs thought by their users to be working. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@791541 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 16bf4246de0..7a1ddbc53c7 100644 --- a/CHANGES +++ b/CHANGES @@ -27,6 +27,9 @@ Changes with Apache 2.2.12 different security issues which may affect particular configurations and third-party modules. + *) mod_alias: Ensure Redirect emits HTTP-compliant URLs. + PR 44020 + *) mod_proxy_http: fix case sensitivity checking transfer encoding PR 47383 [Ryuzo Yamamoto ] diff --git a/STATUS b/STATUS index 2ae4e777be1..6a8ccd6dde6 100644 --- a/STATUS +++ b/STATUS @@ -85,16 +85,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_alias: Ensure Redirect emits HTTP-compliant URLs. - PR 44020 - trunk patch: - http://svn.apache.org/viewvc?view=rev&rev=785575 - 2.2.x patch: - http://people.apache.org/~rpluem/patches/foreign_patches/niq_44020.diff - NOTE: I'm recommending different versions because the trunk - patch is too strict for a stable line and may "break" broken - configs thought by their users to be working. - +1: niq, rpluem, jim PATCHES PROPOSED TO BACKPORT FROM TRUNK: diff --git a/modules/mappers/mod_alias.c b/modules/mappers/mod_alias.c index bde1703de7d..65a720a4fa4 100644 --- a/modules/mappers/mod_alias.c +++ b/modules/mappers/mod_alias.c @@ -405,8 +405,29 @@ static int translate_alias_redir(request_rec *r) if ((ret = try_alias_list(r, serverconf->redirects, 1, &status)) != NULL) { if (ap_is_HTTP_REDIRECT(status)) { - /* include QUERY_STRING if any */ - if (r->args) { + char *orig_target = ret; + if (ret[0] == '/') { + + ret = ap_construct_url(r->pool, ret, r); + ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, + "incomplete redirection target of '%s' for " + "URI '%s' modified to '%s'", + orig_target, r->uri, ret); + } + if (!ap_is_url(ret)) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + "cannot redirect '%s' to '%s'; " + "target is not a valid absoluteURI or abs_path", + r->uri, ret); + /* restore the config value, so as not to get a + * "regression" on existing "working" configs. + */ + ret = orig_target; + } + /* append requested query only, if the config didn't + * supply its own. + */ + if (r->args && !ap_strchr(ret, '?')) { ret = apr_pstrcat(r->pool, ret, "?", r->args, NULL); } apr_table_setn(r->headers_out, "Location", ret);