httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject cvs commit: httpd-apreq-2/src apreq_parsers.c
Date Thu, 24 Apr 2003 15:02:49 GMT
joes        2003/04/24 08:02:49

  Modified:    src      apreq_parsers.c
  Log:
  Use APR's Boyer-Moore-Horspool algorithm (from apr_strmatch.h) in mfd parser to search for
boundary strings.
  
  Revision  Changes    Path
  1.19      +26 -9     httpd-apreq-2/src/apreq_parsers.c
  
  Index: apreq_parsers.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq_parsers.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- apreq_parsers.c	21 Apr 2003 16:09:09 -0000	1.18
  +++ apreq_parsers.c	24 Apr 2003 15:02:49 -0000	1.19
  @@ -60,6 +60,7 @@
   #include "apreq_env.h"
   #include "apr_lib.h"
   #include "apr_strings.h"
  +#include "apr_strmatch.h"
   
   #ifndef MAX
   #define MAX(A,B)  ( (A) > (B) ? (A) : (B) )
  @@ -580,16 +581,18 @@
   /********************* multipart/form-data *********************/
   
   struct mfd_ctx {
  -    void                *hook_data;
  -    apreq_table_t       *t;
  -    apr_bucket_brigade  *bb;
  -    char                bdry[1];
  +    void                        *hook_data;
  +    apreq_table_t               *t;
  +    apr_bucket_brigade          *bb;
  +    const apr_strmatch_pattern  *pattern;
  +    char                         bdry[1];
   };
   
   
   static apr_status_t split_on_bdry(apr_pool_t *pool, 
                                     apr_bucket_brigade *out,
                                     apr_bucket_brigade *in,
  +                                  const apr_strmatch_pattern *pattern,
                                     const char *bdry)
   {
       apr_bucket *e = APR_BRIGADE_FIRST(in);
  @@ -641,7 +644,18 @@
               off = 0;
           }
   
  -        idx = apreq_index(buf, len, bdry, blen, PARTIAL);
  +        if (pattern != NULL && len >= blen) {
  +            const char *match = apr_strmatch(pattern, buf, len);
  +            if (match != NULL)
  +                idx = match - buf;
  +            else {
  +                idx = apreq_index(buf + len-blen, blen, bdry, blen, PARTIAL);
  +                if (idx >= 0)
  +                    idx += len-blen;
  +            }
  +        }
  +        else
  +            idx = apreq_index(buf, len, bdry, blen, PARTIAL);
   
           if (idx > 0)
               apr_bucket_split(e, idx);
  @@ -768,6 +782,7 @@
   
           memcpy(ctx->bdry + 4, bdry, blen);
           ctx->bdry[4 + blen] = 0;
  +        ctx->pattern = apr_strmatch_precompile(pool,ctx->bdry,1);
   
           APR_BRIGADE_INSERT_HEAD(bb,
                     apr_bucket_immortal_create(crlf,2,bb->bucket_alloc));
  @@ -787,7 +802,7 @@
       case MFD_INIT:
           {
               apr_status_t s;
  -            s = split_on_bdry(pool, ctx->bb, bb, ctx->bdry);
  +            s = split_on_bdry(pool, ctx->bb, bb, ctx->pattern, ctx->bdry);
               if (s != APR_SUCCESS)
                   return s;
   
  @@ -798,7 +813,7 @@
       case MFD_NEXTLINE:
           {
               apr_status_t s;
  -            s = split_on_bdry(pool, ctx->bb, bb, crlf);
  +            s = split_on_bdry(pool, ctx->bb, bb, NULL, crlf);
               if (s != APR_SUCCESS)
                   return s;
   
  @@ -863,7 +878,8 @@
   
       case MFD_PARAM:
           {
  -            apr_status_t s = split_on_bdry(pool, ctx->bb, bb, ctx->bdry);
  +            apr_status_t s = split_on_bdry(pool, ctx->bb, bb, 
  +                                           ctx->pattern, ctx->bdry);
               apr_bucket *e;
               apreq_param_t *param;
               apreq_value_t *v;
  @@ -915,7 +931,8 @@
       case MFD_UPLOAD:
           {
               apr_bucket *eos;
  -            apr_status_t s = split_on_bdry(pool, ctx->bb, bb, ctx->bdry);
  +            apr_status_t s = split_on_bdry(pool, ctx->bb, bb, 
  +                                           ctx->pattern, ctx->bdry);
               apreq_param_t *param;
               const apr_array_header_t *arr;
   
  
  
  

Mime
View raw message