Blame SOURCES/php-7.3.11-pcre2.patch

a9582a
Upstream requires pcre2 version 10.30
a9582a
This patch allow 10.23 and set /X default behavior
a9582a
so bad escape raise a compile failure
a9582a
a9582a
a9582a
diff -ru php-7.3.7-old/ext/pcre/config0.m4 php-7.3.7/ext/pcre/config0.m4
a9582a
--- php-7.3.7-old/ext/pcre/config0.m4	2019-07-03 13:30:28.000000000 +0200
a9582a
+++ php-7.3.7/ext/pcre/config0.m4	2019-07-10 17:23:11.963935030 +0200
a9582a
@@ -16,12 +16,12 @@ PHP_ARG_WITH(pcre-jit,,[  --with-pcre-ji
a9582a
         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
a9582a
       fi
a9582a
       if test -x "$PKG_CONFIG"; then
a9582a
-        AC_MSG_CHECKING(for PCRE2 10.30 or greater)
a9582a
-        if $PKG_CONFIG --atleast-version 10.30 libpcre2-8; then
a9582a
+        AC_MSG_CHECKING(for PCRE2 10.23 or greater)
a9582a
+        if $PKG_CONFIG --atleast-version 10.23 libpcre2-8; then
a9582a
           PCRE2_VER=`$PKG_CONFIG --modversion libpcre2-8`
a9582a
           AC_MSG_RESULT($PCRE2_VER)
a9582a
         else
a9582a
-          AC_MSG_ERROR(PCRE2 version 10.30 or later is required to compile php with PCRE2 support)
a9582a
+          AC_MSG_ERROR(PCRE2 version 10.23 or later is required to compile php with PCRE2 support)
a9582a
         fi
a9582a
         PCRE2_LIB=`$PKG_CONFIG --libs libpcre2-8`
a9582a
         PCRE2_INC=`$PKG_CONFIG --cflags libpcre2-8`
a9582a
@@ -33,10 +33,10 @@ PHP_ARG_WITH(pcre-jit,,[  --with-pcre-ji
a9582a
     if test -z "$PCRE2_LIB"; then
a9582a
       PCRE2_CONF=$PHP_PCRE_REGEX/bin/pcre2-config
a9582a
       if test -x "$PCRE2_CONF"; then
a9582a
-        AC_MSG_CHECKING(for PCRE2 10.30 or greater)
a9582a
+        AC_MSG_CHECKING(for PCRE2 10.23 or greater)
a9582a
         PCRE2_VER=`$PCRE2_CONF --version`
a9582a
-        if test "`echo $PCRE2_VER | $SED 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1\2/g'`" -lt "1030"; then
a9582a
-          AC_MSG_ERROR(PCRE2 version 10.30 or later is required to compile php with PCRE2 support)
a9582a
+        if test "`echo $PCRE2_VER | $SED 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1\2/g'`" -lt "1023"; then
a9582a
+          AC_MSG_ERROR(PCRE2 version 10.23 or later is required to compile php with PCRE2 support)
a9582a
         else
a9582a
           AC_MSG_RESULT($PCRE2_VER)
a9582a
         fi
a9582a
diff -ru php-7.3.7-old/ext/pcre/php_pcre.c php-7.3.7/ext/pcre/php_pcre.c
a9582a
--- php-7.3.7-old/ext/pcre/php_pcre.c	2019-07-03 13:30:28.000000000 +0200
a9582a
+++ php-7.3.7/ext/pcre/php_pcre.c	2019-07-11 09:02:59.310972410 +0200
a9582a
@@ -51,7 +51,6 @@ struct _pcre_cache_entry {
a9582a
 	uint32_t capture_count;
a9582a
 	uint32_t name_count;
a9582a
 	uint32_t compile_options;
a9582a
-	uint32_t extra_compile_options;
a9582a
 	uint32_t refcount;
a9582a
 };
a9582a
 
a9582a
@@ -161,7 +160,6 @@ static void php_pcre_free(void *block, v
a9582a
 	pefree(block, 1);
a9582a
 }/*}}}*/
a9582a
 
a9582a
-#define PHP_PCRE_DEFAULT_EXTRA_COPTIONS PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL
a9582a
 #define PHP_PCRE_PREALLOC_MDATA_SIZE 32
a9582a
 
a9582a
 static void php_pcre_init_pcre2(uint8_t jit)
a9582a
@@ -182,12 +180,6 @@ static void php_pcre_init_pcre2(uint8_t
a9582a
 		}
a9582a
 	}
a9582a
 
a9582a
-	/* XXX The 'X' modifier is the default behavior in PCRE2. This option is
a9582a
-		called dangerous in the manual, as typos in patterns can cause
a9582a
-		unexpected results. We might want to to switch to the default PCRE2
a9582a
-		behavior, too, thus causing a certain BC break. */
a9582a
-	pcre2_set_compile_extra_options(cctx, PHP_PCRE_DEFAULT_EXTRA_COPTIONS);
a9582a
-
a9582a
 	if (!mctx) {
a9582a
 		mctx = pcre2_match_context_create(gctx);
a9582a
 		if (!mctx) {
a9582a
@@ -297,7 +289,7 @@ static PHP_INI_MH(OnUpdateRecursionLimit
a9582a
 {/*{{{*/
a9582a
 	OnUpdateLong(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
a9582a
 	if (mctx) {
a9582a
-		pcre2_set_depth_limit(mctx, (uint32_t)PCRE_G(recursion_limit));
a9582a
+		pcre2_set_recursion_limit(mctx, (uint32_t)PCRE_G(recursion_limit));
a9582a
 	}
a9582a
 
a9582a
 	return SUCCESS;
a9582a
@@ -531,7 +523,6 @@ PHPAPI pcre_cache_entry* pcre_get_compil
a9582a
 {
a9582a
 	pcre2_code			*re = NULL;
a9582a
 	uint32_t			 coptions = 0;
a9582a
-	uint32_t			 extra_coptions = PHP_PCRE_DEFAULT_EXTRA_COPTIONS;
a9582a
 	PCRE2_UCHAR	         error[128];
a9582a
 	PCRE2_SIZE           erroffset;
a9582a
 	int                  errnumber;
a9582a
@@ -679,7 +670,7 @@ PHPAPI pcre_cache_entry* pcre_get_compil
a9582a
 			case 'D':	coptions |= PCRE2_DOLLAR_ENDONLY;break;
a9582a
 			case 'S':	/* Pass. */					break;
a9582a
 			case 'U':	coptions |= PCRE2_UNGREEDY;		break;
a9582a
-			case 'X':	extra_coptions &= ~PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL;			break;
a9582a
+			case 'X':	break;
a9582a
 			case 'u':	coptions |= PCRE2_UTF;
a9582a
 	/* In  PCRE,  by  default, \d, \D, \s, \S, \w, and \W recognize only ASCII
a9582a
        characters, even in UTF-8 mode. However, this can be changed by setting
a9582a
@@ -748,19 +739,9 @@ PHPAPI pcre_cache_entry* pcre_get_compil
a9582a
 	}
a9582a
 #endif
a9582a
 
a9582a
-	/* Set extra options for the compile context. */
a9582a
-	if (PHP_PCRE_DEFAULT_EXTRA_COPTIONS != extra_coptions) {
a9582a
-		pcre2_set_compile_extra_options(cctx, extra_coptions);
a9582a
-	}
a9582a
-
a9582a
 	/* Compile pattern and display a warning if compilation failed. */
a9582a
 	re = pcre2_compile((PCRE2_SPTR)pattern, pattern_len, coptions, &errnumber, &erroffset, cctx);
a9582a
 
a9582a
-	/* Reset the compile context extra options to default. */
a9582a
-	if (PHP_PCRE_DEFAULT_EXTRA_COPTIONS != extra_coptions) {
a9582a
-		pcre2_set_compile_extra_options(cctx, PHP_PCRE_DEFAULT_EXTRA_COPTIONS);
a9582a
-	}
a9582a
-
a9582a
 	if (re == NULL) {
a9582a
 #if HAVE_SETLOCALE
a9582a
 		if (key != regex) {
a9582a
@@ -812,7 +793,6 @@ PHPAPI pcre_cache_entry* pcre_get_compil
a9582a
 	new_entry.re = re;
a9582a
 	new_entry.preg_options = poptions;
a9582a
 	new_entry.compile_options = coptions;
a9582a
-	new_entry.extra_compile_options = extra_coptions;
a9582a
 	new_entry.refcount = 0;
a9582a
 
a9582a
 	rc = pcre2_pattern_info(re, PCRE2_INFO_CAPTURECOUNT, &new_entry.capture_count);