MCPcopy Create free account
hub / github.com/apache/httpd / process_regexp

Function process_regexp

modules/metadata/mod_headers.c:629–662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

627 return str ? str : "";
628}
629static const char *process_regexp(header_entry *hdr, const char *value,
630 request_rec *r)
631{
632 ap_regmatch_t pmatch[AP_MAX_REG_MATCH];
633 const char *subs;
634 const char *remainder;
635 char *ret;
636 int diffsz;
637 if (ap_regexec(hdr->regex, value, AP_MAX_REG_MATCH, pmatch, 0)) {
638 /* no match, nothing to do */
639 return value;
640 }
641 /* Process tags in the input string rather than the resulting
642 * substitution to avoid surprises
643 */
644 subs = ap_pregsub(r->pool, process_tags(hdr, r), value, AP_MAX_REG_MATCH, pmatch);
645 if (subs == NULL)
646 return NULL;
647 diffsz = strlen(subs) - (pmatch[0].rm_eo - pmatch[0].rm_so);
648 if (hdr->action == hdr_edit) {
649 remainder = value + pmatch[0].rm_eo;
650 }
651 else { /* recurse to edit multiple matches if applicable */
652 remainder = process_regexp(hdr, value + pmatch[0].rm_eo, r);
653 if (remainder == NULL)
654 return NULL;
655 diffsz += strlen(remainder) - strlen(value + pmatch[0].rm_eo);
656 }
657 ret = apr_palloc(r->pool, strlen(value) + 1 + diffsz);
658 memcpy(ret, value, pmatch[0].rm_so);
659 strcpy(ret + pmatch[0].rm_so, subs);
660 strcat(ret, remainder);
661 return ret;
662}
663
664static int echo_header(void *v, const char *key, const char *val)
665{

Callers 2

edit_headerFunction · 0.85
do_headers_fixupFunction · 0.85

Calls 3

ap_regexecFunction · 0.85
ap_pregsubFunction · 0.85
process_tagsFunction · 0.85

Tested by

no test coverage detected