]> git.ipfire.org Git - thirdparty/apache/httpd.git/commit
mod_headers: Avoid infinite recursion with the edit* action and empty matches.
authorYann Ylavic <ylavic@apache.org>
Tue, 16 Jan 2024 17:40:36 +0000 (17:40 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 16 Jan 2024 17:40:36 +0000 (17:40 +0000)
commit64ecf00d7c1974450bf8780ed1dd3200396745fa
tree0dadd3b7da03b04081a38c3ea7e304a5c06fbad7
parent33edc793fecd3a54aad36f178890d61d4f79ec34
mod_headers: Avoid infinite recursion with the edit* action and empty matches.

Change the recursion used for edit* to a loop using the new ap_regexec_ex()
function taking the current position (offset) in the subject string.

After an empty match do the same thing as pcre2_substitute() (or Perl's /g),
that is: don't allow for another empty match at the same positition by setting
the AP_REG_NOTEMPTY_ATSTART option. If there is a non-empty match use it,
otherwise skip/consume the first character and continue from there.

* modules/metadata/mod_headers.c:
  Rename the hdr_edit_r enum for edit* to hdr_edit_all to better express what
  is does (and since the action is not recursive anymore).

* modules/metadata/mod_headers.c(push_string, push_match):
  New helpers to consume the subject and substitutions in an array of iovec.

* modules/metadata/mod_headers.c(process_regexp):
  Implement the new logic, using push_match() and push_string() to fill the
  iovec array finally passed to apr_strcatv() for the resulting string.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1915271 13f79535-47bb-0310-9956-ffa450edef68
changes-entries/mod_headers-edit_all.txt [new file with mode: 0644]
modules/metadata/mod_headers.c