From: Jim Jagielski Date: Fri, 5 Jun 2026 20:07:27 +0000 (+0000) Subject: Some Perl/Python regex fluff changes - correct the test here. X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=2b33fec6055333a1fc83d1009794740da8de02b7;p=thirdparty%2Fapache%2Fhttpd.git Some Perl/Python regex fluff changes - correct the test here. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1935050 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/test/pytest_suite/tests/t/modules/test_substitute.py b/test/pytest_suite/tests/t/modules/test_substitute.py index 44d1c326b3..810a6005c4 100644 --- a/test/pytest_suite/tests/t/modules/test_substitute.py +++ b/test/pytest_suite/tests/t/modules/test_substitute.py @@ -110,7 +110,11 @@ def _httpd_rule_to_python(content, rule): return re.sub(pattern, lambda m: repl, content, flags=flags) # Map HTTPD $0 (whole match) and $N backrefs to python \g<0> / \N. - # Also handle perl '&' meaning whole match (used in s//&/). + # NOTE: '&' is NOT a whole-match metachar here. mod_substitute uses $0/$N + # for backrefs only, and the Perl reference test computes its expectation by + # running the rule through perl's own s/// (substitute.t:73-80), where a bare + # '&' in the replacement is a literal '&' ($& is the match var, not &). So + # s//&/ yields a literal 'x&x' -- which is what the server returns. def to_py_repl(s): out = [] i = 0 @@ -140,7 +144,9 @@ def _httpd_rule_to_python(content, rule): i += 2 continue if c == "&": - out.append("\\g<0>") + # literal '&' (see note above), not whole-match. '&' has no + # special meaning in an re.sub replacement, so emit it as-is. + out.append("&") i += 1 continue out.append(c)