/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* http_alias.c: Stuff for dealing with directory aliases
*
* Original by Rob McCool, rewritten in succession by David Robinson
* and rst.
*
*/
#include "apr_strings.h"
#include "apr_lib.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "ap_config.h"
#include "httpd.h"
#include "http_core.h"
#include "http_config.h"
#include "http_request.h"
#include "http_log.h"
#include "ap_expr.h"
typedef struct {
const char *real;
const char *fake;
char *handler;
} alias_entry;
typedef struct {
typedef struct {
char *handler;
static char magic_error_value;
{
alias_server_conf *a =
return a;
}
{
alias_dir_conf *a =
return a;
}
{
alias_server_conf *a =
return a;
}
{
alias_dir_conf *a =
a->redirect_status = (overrides->redirect_set == 0) ? base->redirect_status : overrides->redirect_status;
return a;
}
/* need prototype for overlap check */
int use_regex)
{
&alias_module);
int i;
/* XXX: real can NOT be relative to DocumentRoot here... compat bug. */
return err;
}
if (use_regex) {
return "Regular expression could not be compiled.";
}
else {
/* XXX This may be optimized, but we must know that new->real
* exists. If so, we can dir merge later, trusing new->real
* and just canonicalizing the remainder. Not till I finish
* cleaning out the old ap_canonical stuff first.
*/
}
/* check for overlapping (Script)Alias directives
* and throw a warning if found one
*/
if (!use_regex) {
"The %s directive in %s at line %d will probably "
"never match because it overlaps an earlier "
"%sAlias%s.",
break; /* one warning per alias should be sufficient */
}
}
}
return NULL;
}
const char *real)
{
if (real) {
}
else {
return err;
}
return "Alias must have two arguments when used globally";
}
if (err) {
NULL);
}
return NULL;
}
}
{
}
{
&alias_module);
/*
* Logic flow:
* Go ahead and try to grok the 1st arg, in case it is a
* Redirect status. Now if we have 3 args, we expect that
* we were able to understand that 1st argument (it's something
* we expected, so if not, then we bail
*/
else if (apr_isdigit(*arg1))
else
grokarg1 = 0;
return "Redirect: invalid first argument (of three)";
/*
* if we have the 2nd arg and we understand the 1st one, or if we have the
* 1st arg but don't understand it, we use the expression syntax assuming
* a path from the location.
*
* if we understand the first arg but have no second arg, we are dealing
* with a status like "GONE".
*/
if (expr_err) {
NULL);
}
return NULL;
}
return NULL;
}
if (expr_err) {
NULL);
}
return NULL;
}
/*
* if we don't have the 3rd arg and we didn't understand the 1st
* one, then assume URL-path URL. This also handles case, eg, GONE
* we even though we don't have a 3rd arg, we did understand the 1st
* one, so we don't want to re-arrange
*/
}
if (use_regex) {
return "Regular expression could not be compiled.";
}
if (ap_is_HTTP_REDIRECT(status)) {
if (!url)
return "URL to redirect to is missing";
/* PR#35314: we can allow path components here;
* they get correctly resolved to full URLs.
*/
return "Redirect to non-URL";
}
else {
if (url)
return "Redirect URL not valid for this status";
}
else
return NULL;
}
const char *arg3)
{
}
{
}
const char *arg3)
{
}
{
"a fakename and a realname, or a realname in a Location"),
"a fakename and a realname, or a realname in a Location"),
"an optional status, then document to be redirected and "
"destination URL"),
"a regular expression and a filename"),
"a regular expression and a filename"),
(void *) HTTP_MOVED_TEMPORARILY, OR_FILEINFO,
"an optional status, then a regular expression and "
"destination URL"),
(void *) HTTP_MOVED_TEMPORARILY, OR_FILEINFO,
"a document to be redirected, then the destination URL"),
(void *) HTTP_MOVED_PERMANENTLY, OR_FILEINFO,
"a document to be redirected, then the destination URL"),
{NULL}
};
{
while (*aliasp) {
if (*aliasp == '/') {
/* any number of '/' in the alias matches any number in
* the supplied URI, but there must be at least one...
*/
if (*urip != '/')
return 0;
do {
++aliasp;
} while (*aliasp == '/');
do {
++urip;
} while (*urip == '/');
}
else {
/* Other characters are compared literally */
return 0;
}
}
/* Check last alias path component matched all the way */
return 0;
/* Return number of characters from URI which matched (may be
* greater than length of alias, since we may have matched
* doubled slashes)
*/
}
{
if (err) {
"Can't evaluate alias expression: %s", err);
return PREGSUB_ERROR;
}
}
/* XXX This is as SLOW as can be, next step, we optimize
* and merge to whatever part of the found path was already
* canonicalized. After I finish eliminating os canonical.
* Better fail test for ap_server_root_relative needed here.
*/
return found;
}
return NULL;
}
{
if (dirconf->redirect_set) {
if (err) {
"Can't evaluate redirect expression: %s", err);
return PREGSUB_ERROR;
}
/* Do not escape the query string or fragment. */
}
}
}
return found;
}
return NULL;
}
{
int i;
int l;
if (found) {
if (is_redir) {
/* Do not escape the query string or fragment. */
}
}
}
}
else {
"Regex substitution in '%s' failed. "
return PREGSUB_ERROR;
}
}
else {
/* need something non-null */
found = "";
}
}
}
else {
if (l > 0) {
if (is_redir) {
char *escurl;
}
else
}
}
if (found) {
}
/* XXX This is as SLOW as can be, next step, we optimize
* and merge to whatever part of the found path was already
* canonicalized. After I finish eliminating os canonical.
* Better fail test for ap_server_root_relative needed here.
*/
if (!is_redir) {
}
if (found) {
}
return found;
}
}
return NULL;
}
{
char *ret;
int status;
return DECLINED;
}
!= NULL) {
if (ret == PREGSUB_ERROR)
return HTTP_INTERNAL_SERVER_ERROR;
if (ap_is_HTTP_REDIRECT(status)) {
if (ret[0] == '/') {
"incomplete redirection target of '%s' for "
"URI '%s' modified to '%s'",
}
"cannot redirect '%s' to '%s'; "
"target is not a valid absoluteURI or abs_path",
}
else {
/* append requested query only, if the config didn't
* supply its own.
*/
}
}
}
return status;
}
!= NULL) {
return OK;
}
return DECLINED;
}
{
char *ret;
int status;
/* It may have changed since last time, so try again */
!= NULL) {
if (ret == PREGSUB_ERROR)
return HTTP_INTERNAL_SERVER_ERROR;
if (ap_is_HTTP_REDIRECT(status)) {
if (ret[0] == '/') {
"incomplete redirection target of '%s' for "
"URI '%s' modified to '%s'",
}
"cannot redirect '%s' to '%s'; "
"target is not a valid absoluteURI or abs_path",
}
else {
/* append requested query only, if the config didn't
* supply its own.
*/
}
}
}
return status;
}
return DECLINED;
}
{
"mod_vhost_alias.c",NULL };
}
{
create_alias_dir_config, /* dir config creater */
merge_alias_dir_config, /* dir merger --- default is to override */
create_alias_config, /* server config */
merge_alias_config, /* merge server configs */
alias_cmds, /* command apr_table_t */
register_hooks /* register hooks */
};