PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- * mod_substitute: Configure patterns merge order. PR 57641
- trunk patch: http://svn.apache.org/r1684900
- http://svn.apache.org/r1687539
- http://svn.apache.org/r1687680
- http://svn.apache.org/r1688331
- http://svn.apache.org/r1688339
- http://svn.apache.org/r1688340
- http://svn.apache.org/r1688341
- http://svn.apache.org/r1688343
- http://svn.apache.org/r1697013
- http://svn.apache.org/r1697015
- 2.4.x patch: http://people.apache.org/~ylavic/httpd-2.4.x-SubstituteInheritBefore-v6.patch
- +1: ylavic, wrowe, rjung
PATCHES PROPOSED TO BACKPORT FROM TRUNK:
</usage>
</directivesynopsis>
+<directivesynopsis>
+<name>SubstituteInheritBefore</name>
+<description>Change the merge order of inherited patterns</description>
+<syntax>SubstituteInheritBefore on|off</syntax>
+<default>SubstituteInheritBefore off</default>
+<contextlist><context>directory</context>
+<context>.htaccess</context></contextlist>
+<override>FileInfo</override>
+<compatibility>Available in httpd 2.4.17 and later</compatibility>
+
+<usage>
+ <p>Whether to apply the inherited <directive>Substitute</directive>
+ patterns first (<code>on</code>), or after the ones of the current
+ context (<code>off</code>).
+ <directive>SubstituteInheritBefore</directive> is itself inherited,
+ hence contexts that inherit it (those that don't specify their own
+ <directive>SubstituteInheritBefore</directive> value) will apply the
+ closest defined merge order.
+</usage>
+</directivesynopsis>
+
</modulesynopsis>
apr_array_header_t *patterns;
apr_size_t max_line_length;
int max_line_length_set;
+ int inherit_before;
} subst_dir_conf;
typedef struct {
static void *create_substitute_dcfg(apr_pool_t *p, char *d)
{
subst_dir_conf *dcfg =
- (subst_dir_conf *) apr_pcalloc(p, sizeof(subst_dir_conf));
+ (subst_dir_conf *) apr_palloc(p, sizeof(subst_dir_conf));
dcfg->patterns = apr_array_make(p, 10, sizeof(subst_pattern_t));
dcfg->max_line_length = AP_SUBST_MAX_LINE_LENGTH;
+ dcfg->max_line_length_set = 0;
+ dcfg->inherit_before = -1;
return dcfg;
}
static void *merge_substitute_dcfg(apr_pool_t *p, void *basev, void *overv)
{
subst_dir_conf *a =
- (subst_dir_conf *) apr_pcalloc(p, sizeof(subst_dir_conf));
+ (subst_dir_conf *) apr_palloc(p, sizeof(subst_dir_conf));
subst_dir_conf *base = (subst_dir_conf *) basev;
subst_dir_conf *over = (subst_dir_conf *) overv;
- a->patterns = apr_array_append(p, over->patterns,
- base->patterns);
+ a->inherit_before = (over->inherit_before != -1)
+ ? over->inherit_before
+ : base->inherit_before;
+ /* SubstituteInheritBefore wasn't the default behavior until 2.5.x,
+ * and may be re-disabled as desired; the original default behavior
+ * was to apply inherited subst patterns after locally scoped patterns.
+ * In later 2.2 and 2.4 versions, SubstituteInheritBefore may be toggled
+ * 'on' to follow the corrected/expected behavior, without violating POLS.
+ */
+ if (a->inherit_before == 1) {
+ 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 ?
- over->max_line_length_set : base->max_line_length_set;
+ over->max_line_length : base->max_line_length;
+ a->max_line_length_set = over->max_line_length_set
+ | base->max_line_length_set;
return a;
}
"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", ap_set_flag_slot,
+ (void *)APR_OFFSETOF(subst_dir_conf, inherit_before), OR_FILEINFO,
+ "Apply inherited patterns before those of the current context"),
{NULL}
};