On Sat, Feb 15, 2020 at 7:16 PM <[email protected]> wrote:
>
> --- httpd/httpd/branches/2.4.x/STATUS (original)
> +++ httpd/httpd/branches/2.4.x/STATUS Sat Feb 15 18:16:31 2020
> @@ -133,6 +133,8 @@ RELEASE SHOWSTOPPERS:
> trunk patch: http://svn.apache.org/viewvc?rev=1873941&view=rev
> 2.4.x patch:
> http://people.apache.org/~covener/patches/httpd-2.4.x-substitute-nodotall.diff
> +1 covener, rpluem, jim, ylavic
> + jailletc36: This needs some doc update (RegexDefaultOptions and
> certainly somewhere
> + for the util_regex.c stuff, but I've not found where :( ).
I wonder if, instead of "exposing" NO_DOTALL, we shouldn't have
AP_REG_NO_DEFAULT used internally only.
There is already a way to disable DOTALL in RegexDefaultOptions (with
-DOTALL), and the internal changes to ap_regcomp() and
ap_rxplus_compile() could use AP_REG_NO_DEFAULT instead of
AP_REG_NO_DOTALL, avoiding to add more NO_* options later (possibly).
For mod_substitute, AP_REG_NO_DEFAULT (besides sensible
AP_REG_DOLLAR_ENDONLY) would be set since flags can be set explicitely
too.
Something like the attached patch (over trunk's r1873941)?
Regards,
Yann.
Index: include/ap_mmn.h
===================================================================
--- include/ap_mmn.h (revision 1874061)
+++ include/ap_mmn.h (working copy)
@@ -620,7 +620,7 @@
* 20190312.6 (2.5.1-dev) Add proxy check_trans hook
* 20190312.7 (2.5.1-dev) AP_REG_DEFAULT macro in ap_regex.h
* 20190312.8 (2.5.1-dev) ap_is_chunked() in httpd.h
- * 20190312.9 (2.5.1-dev) AP_REG_NO_DOTALL macro in ap_regex.h
+ * 20190312.9 (2.5.1-dev) AP_REG_NO_DEFAULT macro in ap_regex.h
*/
#define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
Index: include/ap_regex.h
===================================================================
--- include/ap_regex.h (revision 1874061)
+++ include/ap_regex.h (working copy)
@@ -87,7 +87,7 @@ extern "C" {
#define AP_REG_DOLLAR_ENDONLY 0x200 /**< '$' matches at end of subject string only */
-#define AP_REG_NO_DOTALL 0x400 /**< remove AP_REG_DOTALL from defaults */
+#define AP_REG_NO_DEFAULT 0x400 /**< Don't implicitely add AP_REG_DEFAULT options */
#define AP_REG_MATCH "MATCH_" /**< suggested prefix for ap_regname */
Index: server/util_pcre.c
===================================================================
--- server/util_pcre.c (revision 1874061)
+++ server/util_pcre.c (working copy)
@@ -179,9 +179,6 @@ AP_DECLARE(int) ap_regcomp_default_cflag_by_name(c
else if (ap_cstr_casecmp(name, "DOTALL") == 0) {
cflag = AP_REG_DOTALL;
}
- else if (ap_cstr_casecmp(name, "NO_DOTALL") == 0) {
- cflag = AP_REG_NO_DOTALL;
- }
else if (ap_cstr_casecmp(name, "DOLLAR_ENDONLY") == 0) {
cflag = AP_REG_DOLLAR_ENDONLY;
}
@@ -213,7 +210,9 @@ AP_DECLARE(int) ap_regcomp(ap_regex_t * preg, cons
int errcode = 0;
int options = PCREn(DUPNAMES);
- cflags |= default_cflags;
+ if ((cflags & AP_REG_NO_DEFAULT) == 0)
+ cflags |= default_cflags;
+
if ((cflags & AP_REG_ICASE) != 0)
options |= PCREn(CASELESS);
if ((cflags & AP_REG_NEWLINE) != 0)
@@ -220,8 +219,6 @@ AP_DECLARE(int) ap_regcomp(ap_regex_t * preg, cons
options |= PCREn(MULTILINE);
if ((cflags & AP_REG_DOTALL) != 0)
options |= PCREn(DOTALL);
- if ((cflags & AP_REG_NO_DOTALL) != 0)
- options &= ~PCREn(DOTALL);
if ((cflags & AP_REG_DOLLAR_ENDONLY) != 0)
options |= PCREn(DOLLAR_ENDONLY);
Index: server/util_regex.c
===================================================================
--- server/util_regex.c (revision 1874061)
+++ server/util_regex.c (working copy)
@@ -94,6 +94,7 @@ AP_DECLARE(ap_rxplus_t*) ap_rxplus_compile(apr_poo
}
/* anything after the current delimiter is flags */
+ ret->flags |= AP_REG_DOLLAR_ENDONLY;
while (*++endp) {
switch (*endp) {
case 'i': ret->flags |= AP_REG_ICASE; break;
@@ -101,13 +102,12 @@ AP_DECLARE(ap_rxplus_t*) ap_rxplus_compile(apr_poo
case 'n': ret->flags |= AP_REG_NOMEM; break;
case 'g': ret->flags |= AP_REG_MULTI; break;
case 's': ret->flags |= AP_REG_DOTALL; break;
- case 'S': ret->flags |= AP_REG_NO_DOTALL; break;
case '^': ret->flags |= AP_REG_NOTBOL; break;
case '$': ret->flags |= AP_REG_NOTEOL; break;
default: break; /* we should probably be stricter here */
}
}
- if (ap_regcomp(&ret->rx, rxstr, ret->flags) == 0) {
+ if (ap_regcomp(&ret->rx, rxstr, AP_REG_NO_DEFAULT | ret->flags) == 0) {
apr_pool_cleanup_register(pool, &ret->rx, rxplus_cleanup,
apr_pool_cleanup_null);
}
Index: modules/filters/mod_substitute.c
===================================================================
--- modules/filters/mod_substitute.c (revision 1874061)
+++ modules/filters/mod_substitute.c (working copy)
@@ -716,8 +716,9 @@ static const char *set_pattern(cmd_parms *cmd, voi
/* first see if we can compile the regex */
if (!is_pattern) {
- r = ap_pregcomp(cmd->pool, from, AP_REG_NO_DOTALL | AP_REG_EXTENDED |
- (ignore_case ? AP_REG_ICASE : 0));
+ r = ap_pregcomp(cmd->pool, from, AP_REG_NO_DEFAULT | AP_REG_EXTENDED |
+ (ignore_case ? AP_REG_ICASE : 0) |
+ AP_REG_DOLLAR_ENDONLY);
if (!r)
return "Substitute could not compile regex";
}