From 3b3117e96bc9c2afaeb5b98e9b60315006679a6d Mon Sep 17 00:00:00 2001
From: Stefan Eissing <icing@apache.org>
Date: Fri, 2 Aug 2019 09:24:58 +0000
Subject: [PATCH] Merge of r1864192 from trunk:

  *) core, rewrite: Set PCRE_DOTALL by default



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1864213 13f79535-47bb-0310-9956-ffa450edef68
---
 CHANGES                  |  3 +++
 STATUS                   |  5 -----
 docs/manual/mod/core.xml | 20 +++++++++++---------
 server/util_pcre.c       |  3 ++-
 4 files changed, 16 insertions(+), 15 deletions(-)

# diff --git a/CHANGES b/CHANGES
# index bf00b5114b..ad4fd27625 100644
# --- a/CHANGES
# +++ b/CHANGES
# @@ -1,6 +1,9 @@
#                                                           -*- coding: utf-8 -*-
#  Changes with Apache 2.4.40
#  
# +  *) core, mod_rewrite: Set PCRE_DOTALL by default. Revert via 
# +     RegexDefaultOptions -DOTALL [Yann Ylavic]
# +
#    *) core: Remove request details from built-in error documents [Eric Covener]
#  
#    *) mod_http2: core setting "LimitRequestFieldSize" is not additionally checked on
# diff --git a/STATUS b/STATUS
# index 3c3cf39f48..f9bfc678fd 100644
# --- a/STATUS
# +++ b/STATUS
# @@ -127,11 +127,6 @@ RELEASE SHOWSTOPPERS:
#  PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
#    [ start all new proposals below, under PATCHES PROPOSED. ]
#  
# -  *) core, rewrite: Set PCRE_DOTALL by default
# -     trunk: http://svn.apache.org/1864192
# -     2.4.x: svn merge  -c 1864192 ^/httpd/httpd/trunk .
# -     +1: covener, rpluem, icing
# -
#  
#  PATCHES PROPOSED TO BACKPORT FROM TRUNK:
#    [ New proposals should be added at the end of the list ]
# diff --git a/docs/manual/mod/core.xml b/docs/manual/mod/core.xml
# index d9f0895af4..d4d6030dc5 100644
# --- a/docs/manual/mod/core.xml
# +++ b/docs/manual/mod/core.xml
# @@ -4061,7 +4061,7 @@ Protocols h2 http/1.1
#      <name>RegexDefaultOptions</name>
#      <description>Allow to configure global/default options for regexes</description>
#      <syntax>RegexDefaultOptions [none] [+|-]<var>option</var> [[+|-]<var>option</var>] ...</syntax>
# -    <default>RegexDefaultOptions DOLLAR_ENDONLY</default>
# +    <default>RegexDefaultOptions DOTALL DOLLAR_ENDONLY</default>
#      <contextlist><context>server config</context></contextlist>
#      <compatibility>Only available from Apache 2.4.30 and later.</compatibility>
#      
# @@ -4080,24 +4080,26 @@ Protocols h2 http/1.1
#              <dt><code>ICASE</code></dt>
#              <dd>Use a case-insensitive match.</dd>
#  
# +            <dt><code>EXTENDED</code></dt>
# +            <dd>Perl's /x flag, ignore (unescaped-)spaces and comments in the pattern.</dd>
# +
#              <dt><code>DOTALL</code></dt>
# -            <dd>Perl's /s flag.</dd>
# +            <dd>Perl's /s flag, '.' matches newline characters.</dd>
#  
#              <dt><code>DOLLAR_ENDONLY</code></dt>
#              <dd>'$' matches at end of subject string only.</dd>
# -            <dd>.</dd>
#          </dl>
#          <highlight language="config">
# -# 
# -RegexDefaultOptions +ICASE +DOLLAR_ENDONLY
# +# Add the ICASE option for all regexes by default
# +RegexDefaultOptions +ICASE
#  ...
# -# Remove the ICASE option, but keep all the other already set options
# -RegexDefaultOptions -ICASE
# +# Remove the default DOLLAR_ENDONLY option, but keep any other one
# +RegexDefaultOptions -DOLLAR_ENDONLY
#  ...
# -# Set the default option to DOTALL, resetting any other option
# +# Set the DOTALL option only, resetting any other one
#  RegexDefaultOptions DOTALL
#  ...
# -# Reset all defined option
# +# Reset all defined options
#  RegexDefaultOptions none
#  ...
#          </highlight>
# diff --git a/docs/manual/mod/core.html.en b/docs/manual/mod/core.html.en
# index 1cc985eb65..4c0b2fd744 100644
# --- a/docs/manual/mod/core.html.en
# +++ b/docs/manual/mod/core.html.en
# @@ -4069,7 +4069,7 @@ as if 'QualifyRedirectURL ON' was configured.</td></tr>
#  <table class="directive">
#  <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Allow to configure global/default options for regexes</td></tr>
#  <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RegexDefaultOptions [none] [+|-]<var>option</var> [[+|-]<var>option</var>] ...</code></td></tr>
# -<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RegexDefaultOptions DOLLAR_ENDONLY</code></td></tr>
# +<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>RegexDefaultOptions DOTALL DOLLAR_ENDONLY</code></td></tr>
#  <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr>
#  <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Core</td></tr>
#  <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>core</td></tr>
# @@ -4089,23 +4089,25 @@ as if 'QualifyRedirectURL ON' was configured.</td></tr>
#              <dt><code>ICASE</code></dt>
#              <dd>Use a case-insensitive match.</dd>
#  
# +            <dt><code>EXTENDED</code></dt>
# +            <dd>Perl's /x flag, ignore (unescaped-)spaces and comments in the pattern.</dd>
# +
#              <dt><code>DOTALL</code></dt>
# -            <dd>Perl's /s flag.</dd>
# +            <dd>Perl's /s flag, '.' matches newline characters.</dd>
#  
#              <dt><code>DOLLAR_ENDONLY</code></dt>
#              <dd>'$' matches at end of subject string only.</dd>
# -            <dd>.</dd>
#          </dl>
# -        <pre class="prettyprint lang-config"># 
# -RegexDefaultOptions +ICASE +DOLLAR_ENDONLY
# +        <pre class="prettyprint lang-config"># Add the ICASE option for all regexes by default
# +RegexDefaultOptions +ICASE
#  ...
# -# Remove the ICASE option, but keep all the other already set options
# -RegexDefaultOptions -ICASE
# +# Remove the default DOLLAR_ENDONLY option, but keep any other one
# +RegexDefaultOptions -DOLLAR_ENDONLY
#  ...
# -# Set the default option to DOTALL, resetting any other option
# +# Set the DOTALL option only, resetting any other one
#  RegexDefaultOptions DOTALL
#  ...
# -# Reset all defined option
# +# Reset all defined options
#  RegexDefaultOptions none
#  ...</pre>
#  
diff --git a/server/util_pcre.c b/server/util_pcre.c
index f2cb1bb01e..35831f500f 100644
--- a/server/util_pcre.c
+++ b/server/util_pcre.c
@@ -120,7 +120,8 @@ AP_DECLARE(void) ap_regfree(ap_regex_t *preg)
  *            Compile a regular expression       *
  *************************************************/
 
-static int default_cflags = AP_REG_DOLLAR_ENDONLY;
+static int default_cflags = AP_REG_DOTALL |
+                            AP_REG_DOLLAR_ENDONLY;
 
 AP_DECLARE(int) ap_regcomp_get_default_cflags(void)
 {
-- 
2.17.1

