You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2020/02/19 12:26:31 UTC

svn commit: r1874191 - in /httpd/httpd/branches/2.4.x: include/ap_mmn.h include/ap_regex.h modules/filters/mod_substitute.c server/util_pcre.c server/util_regex.c

Author: covener
Date: Wed Feb 19 12:26:31 2020
New Revision: 1874191

URL: http://svn.apache.org/viewvc?rev=1874191&view=rev
Log:
add AP_REG_NO_DEFAULT to allow opt-out of pcre defaults

... and use it in mod_substitute to avoid DOTALL


Modified:
    httpd/httpd/branches/2.4.x/include/ap_mmn.h
    httpd/httpd/branches/2.4.x/include/ap_regex.h
    httpd/httpd/branches/2.4.x/modules/filters/mod_substitute.c
    httpd/httpd/branches/2.4.x/server/util_pcre.c
    httpd/httpd/branches/2.4.x/server/util_regex.c

Modified: httpd/httpd/branches/2.4.x/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/ap_mmn.h?rev=1874191&r1=1874190&r2=1874191&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/ap_mmn.h (original)
+++ httpd/httpd/branches/2.4.x/include/ap_mmn.h Wed Feb 19 12:26:31 2020
@@ -533,6 +533,7 @@
  *                          AP_VOLATILIZE_T.
  * 20120211.90 (2.4.42-dev) AP_REG_DEFAULT macro in ap_regex.h
  * 20120211.91 (2.4.42-dev) Add ap_is_chunked() in httpd.h
+ * 20120211.92 (2.4.42-dev) AP_REG_NO_DEFAULT macro in ap_regex.h
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -540,7 +541,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20120211
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 91                  /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 92                  /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/branches/2.4.x/include/ap_regex.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/ap_regex.h?rev=1874191&r1=1874190&r2=1874191&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/ap_regex.h (original)
+++ httpd/httpd/branches/2.4.x/include/ap_regex.h Wed Feb 19 12:26:31 2020
@@ -84,7 +84,9 @@ extern "C" {
 
 #define AP_REG_DOLLAR_ENDONLY 0x200 /* '$' matches at end of subject string only */
 
-#define AP_REG_MATCH "MATCH_" /** suggested prefix for ap_regname */
+#define AP_REG_NO_DEFAULT 0x400 /**< Don't implicitely add AP_REG_DEFAULT options */
+
+#define AP_REG_MATCH "MATCH_" /**< suggested prefix for ap_regname */
 
 #define AP_REG_DEFAULT (AP_REG_DOTALL|AP_REG_DOLLAR_ENDONLY)
 

Modified: httpd/httpd/branches/2.4.x/modules/filters/mod_substitute.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/filters/mod_substitute.c?rev=1874191&r1=1874190&r2=1874191&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/filters/mod_substitute.c (original)
+++ httpd/httpd/branches/2.4.x/modules/filters/mod_substitute.c Wed Feb 19 12:26:31 2020
@@ -667,8 +667,10 @@ static const char *set_pattern(cmd_parms
 
     /* first see if we can compile the regex */
     if (!is_pattern) {
-        r = ap_pregcomp(cmd->pool, from, AP_REG_EXTENDED |
-                        (ignore_case ? AP_REG_ICASE : 0));
+        int flags = AP_REG_NO_DEFAULT
+                    | (ap_regcomp_get_default_cflags() & AP_REG_DOLLAR_ENDONLY)
+                    | (ignore_case ? AP_REG_ICASE : 0);
+        r = ap_pregcomp(cmd->pool, from, flags);
         if (!r)
             return "Substitute could not compile regex";
     }

Modified: httpd/httpd/branches/2.4.x/server/util_pcre.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/util_pcre.c?rev=1874191&r1=1874190&r2=1874191&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/util_pcre.c (original)
+++ httpd/httpd/branches/2.4.x/server/util_pcre.c Wed Feb 19 12:26:31 2020
@@ -168,7 +168,9 @@ AP_DECLARE(int) ap_regcomp(ap_regex_t *
     int errcode = 0;
     int options = PCRE_DUPNAMES;
 
-    cflags |= default_cflags;
+    if ((cflags & AP_REG_NO_DEFAULT) == 0)
+        cflags |= default_cflags;
+
     if ((cflags & AP_REG_ICASE) != 0)
         options |= PCRE_CASELESS;
     if ((cflags & AP_REG_NEWLINE) != 0)

Modified: httpd/httpd/branches/2.4.x/server/util_regex.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/util_regex.c?rev=1874191&r1=1874190&r2=1874191&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/util_regex.c (original)
+++ httpd/httpd/branches/2.4.x/server/util_regex.c Wed Feb 19 12:26:31 2020
@@ -94,6 +94,7 @@ AP_DECLARE(ap_rxplus_t*) ap_rxplus_compi
     }
 
     /* anything after the current delimiter is flags */
+    ret->flags = ap_regcomp_get_default_cflags() & AP_REG_DOLLAR_ENDONLY;
     while (*++endp) {
         switch (*endp) {
         case 'i': ret->flags |= AP_REG_ICASE; break;
@@ -106,7 +107,7 @@ AP_DECLARE(ap_rxplus_t*) ap_rxplus_compi
         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);
     }