From: Yann Ylavic Date: Thu, 25 Jun 2015 14:50:55 +0000 (+0000) Subject: mod_substitute: follow up r1684900. X-Git-Tag: 2.5.0-alpha~3050 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85fad62c0c025172718ab021f430bda767d64742;p=thirdparty%2Fapache%2Fhttpd.git mod_substitute: follow up r1684900. Introduce the SubstituteInheritBefore directive to configure the merge order. This allows to preserve 2.4 and earlier behaviour. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1687539 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/mod/mod_substitute.xml b/docs/manual/mod/mod_substitute.xml index 6b7082fe001..4ccc08884a0 100644 --- a/docs/manual/mod/mod_substitute.xml +++ b/docs/manual/mod/mod_substitute.xml @@ -162,4 +162,28 @@ Substitute "s|http://internal.blog.example.com/|http://www.example.com/blog/|i" + +SubstituteInheritBefore +Change the merge order of inherited patterns +SubstituteInheritBefore on|off +SubstituteInheritBefore off +directory +.htaccess +FileInfo +Available in httpd 2.4.17 and later + + +

Whether to apply the inherited Substitute + patterns first (on), or after the ones of the current + context (off). + The former was the default in versions 2.4 and earlier, but changed + starting with 2.5, hence SubstituteInheritBefore + set to on allows to restore the legacy behaviour. + SubstituteInheritBefore is itself inherited, + hence contexts that inherit it (those that don't specify their own + SubstituteInheritBefore value) will apply the + closest defined merge order. + + + diff --git a/modules/filters/mod_substitute.c b/modules/filters/mod_substitute.c index 22f75dce56e..eb126847de4 100644 --- a/modules/filters/mod_substitute.c +++ b/modules/filters/mod_substitute.c @@ -57,6 +57,8 @@ typedef struct { apr_array_header_t *patterns; apr_size_t max_line_length; int max_line_length_set; + int inherit_before_set, + inherit_before; } subst_dir_conf; typedef struct { @@ -84,8 +86,17 @@ static void *merge_substitute_dcfg(apr_pool_t *p, void *basev, void *overv) subst_dir_conf *base = (subst_dir_conf *) basev; subst_dir_conf *over = (subst_dir_conf *) overv; - a->patterns = apr_array_append(p, base->patterns, - over->patterns); + if (!over->inherit_before_set) { + over->inherit_before = base->inherit_before; + } + if (over->inherit_before) { + a->patterns = apr_array_append(p, base->patterns, + over->patterns); + } + else { + a->patterns = apr_array_append(p, over->patterns, + base->patterns); + } a->max_line_length = over->max_line_length_set ? over->max_line_length : base->max_line_length; a->max_line_length_set = over->max_line_length_set ? @@ -683,6 +694,16 @@ static const char *set_max_line_length(cmd_parms *cmd, void *cfg, const char *ar return NULL; } +static const char *set_inherit_before(cmd_parms *cmd, void *cfg, int flag) +{ + subst_dir_conf *dcfg = (subst_dir_conf *)cfg; + + dcfg->inherit_before = (flag != 0); + dcfg->inherit_before_set = 1; + + return NULL; +} + #define PROTO_FLAGS AP_FILTER_PROTO_CHANGE|AP_FILTER_PROTO_CHANGE_LENGTH static void register_hooks(apr_pool_t *pool) { @@ -695,6 +716,8 @@ static const command_rec substitute_cmds[] = { "Pattern to filter the response content (s/foo/bar/[inf])"), AP_INIT_TAKE1("SubstituteMaxLineLength", set_max_line_length, NULL, OR_FILEINFO, "Maximum line length"), + AP_INIT_FLAG("SubstituteInheritBefore", set_inherit_before, NULL, OR_FILEINFO, + "Apply inherited patterns before those of the current context"), {NULL} };