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
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 ]
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;
}