httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ruediger Pluem <rpl...@apache.org>
Subject Re: svn commit: r894036 - in /httpd/httpd/trunk: CHANGES docs/manual/mod/mod_headers.xml modules/metadata/mod_headers.c
Date Thu, 15 Jul 2010 19:20:54 GMT


On 12/27/2009 01:05 AM, niq@apache.org wrote:
> Author: niq
> Date: Sun Dec 27 00:05:12 2009
> New Revision: 894036
> 
> URL: http://svn.apache.org/viewvc?rev=894036&view=rev
> Log:
> mod_headers: Enable multi-match-and-replace edit option
> PR 47066
> 
> Modified:
>     httpd/httpd/trunk/CHANGES
>     httpd/httpd/trunk/docs/manual/mod/mod_headers.xml
>     httpd/httpd/trunk/modules/metadata/mod_headers.c
> 

> Modified: httpd/httpd/trunk/modules/metadata/mod_headers.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/metadata/mod_headers.c?rev=894036&r1=894035&r2=894036&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/modules/metadata/mod_headers.c (original)
> +++ httpd/httpd/trunk/modules/metadata/mod_headers.c Sun Dec 27 00:05:12 2009

> @@ -566,6 +570,7 @@
>      unsigned int nmatch = 10;
>      ap_regmatch_t pmatch[10];
>      const char *subs;
> +    const char *remainder;
>      char *ret;
>      int diffsz;
>      if (ap_regexec(hdr->regex, value, nmatch, pmatch, 0)) {
> @@ -574,6 +579,13 @@
>      }
>      subs = ap_pregsub(pool, hdr->subs, value, nmatch, pmatch);
>      diffsz = strlen(subs) - (pmatch[0].rm_eo - pmatch[0].rm_so);
> +    if (hdr->action == hdr_edit) {
> +        remainder = value + pmatch[0].rm_eo;
> +    }
> +    else { /* recurse to edit multiple matches if applicable */
> +        remainder = process_regexp(hdr, value + pmatch[0].rm_eo, pool);
> +        diffsz += strlen(remainder) - strlen(value + pmatch[0].rm_eo);
> +    }
>      ret = apr_palloc(pool, strlen(value) + 1 + diffsz);
>      memcpy(ret, value, pmatch[0].rm_so);
>      strcpy(ret + pmatch[0].rm_so, subs);
> @@ -722,6 +734,7 @@
>                           echo_header, (void *) &v, r->headers_in, NULL);
>              break;
>          case hdr_edit:
> +        case hdr_edit_r:
>              if (!strcasecmp(hdr->header, "Content-Type") && r->content_type)
{
>                  ap_set_content_type(r, process_regexp(hdr, r->content_type,
>                                                        r->pool));
> 
> 

Don't we need the following patch in addition?

Index: mod_headers.c
===================================================================
--- mod_headers.c       (Revision 964531)
+++ mod_headers.c       (Arbeitskopie)
@@ -592,7 +592,7 @@
     ret = apr_palloc(pool, strlen(value) + 1 + diffsz);
     memcpy(ret, value, pmatch[0].rm_so);
     strcpy(ret + pmatch[0].rm_so, subs);
-    strcat(ret, value + pmatch[0].rm_eo);
+    strcat(ret, remainder);
     return ret;
 }


Regards

RĂ¼diger


Mime
View raw message