From cdf5055ed0cca53eb3c8a4d3c9136e875c2bf1c8 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Tue, 3 Apr 2012 12:39:07 +0000 Subject: [PATCH] Merge r1307067 from trunk: Fix treatment of regex backreferences. r904765 only made half of the necessary changes to remove the use of '&' as an alias for '$0' and allow to escape any character with a backslash. Submitted by: sf Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1308863 13f79535-47bb-0310-9956-ffa450edef68 --- STATUS | 6 ------ server/util.c | 6 ++---- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/STATUS b/STATUS index 1b09575c5d..1b99293e01 100644 --- a/STATUS +++ b/STATUS @@ -88,12 +88,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * core: Fix regexp substitution bug - Trunk patch: http://svn.apache.org/viewvc?rev=1307067&view=rev - 2.4.x patch: Trunk patch works, add CHANGES: - core: Fix regular expression substitution if the replacment string - contained '&' or '\'. (Bug introduced in 2.3.5). - +1: sf, covener, jim PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/server/util.c b/server/util.c index 3c38fa9008..177f3780fc 100644 --- a/server/util.c +++ b/server/util.c @@ -437,15 +437,13 @@ static apr_status_t regsub_core(apr_pool_t *p, char **result, src = input; while ((c = *src++) != '\0') { - if (c == '&') - no = 0; - else if (c == '$' && apr_isdigit(*src)) + if (c == '$' && apr_isdigit(*src)) no = *src++ - '0'; else no = AP_MAX_REG_MATCH; if (no >= AP_MAX_REG_MATCH) { /* Ordinary character. */ - if (c == '\\' && (*src == '$' || *src == '&')) + if (c == '\\' && *src) c = *src++; *dst++ = c; } -- 2.40.0